test: add more extension option tests

This commit is contained in:
Philipp Kühn
2021-04-17 21:25:04 +02:00
parent 47032bf96d
commit b1aa7863e8

View File

@@ -3,7 +3,7 @@
import { Extension } from '@tiptap/core/src/Extension'
describe('extension options', () => {
it('should pass through', () => {
it('should set options', () => {
const extension = Extension.create({
defaultOptions: {
foo: 1,
@@ -17,6 +17,23 @@ describe('extension options', () => {
})
})
it('should pass through', () => {
const extension = Extension
.create({
defaultOptions: {
foo: 1,
bar: 1,
},
})
.extend()
.configure()
expect(extension.options).to.deep.eq({
foo: 1,
bar: 1,
})
})
it('should be configurable', () => {
const extension = Extension
.create({
@@ -35,24 +52,44 @@ describe('extension options', () => {
})
})
// TODO: this fails. not sure about it
it('should be extendable', () => {
const extension = Extension.create({
defaultOptions: {
foo: 1,
bar: 1,
},
})
// it('should be extendable', () => {
// const extension = Extension
// .create({
// defaultOptions: {
// foo: 1,
// bar: 1,
// },
// })
// .extend({
// defaultOptions: {
// baz: 1,
// },
// })
const newExtension = extension.extend({
defaultOptions: {
...extension.options,
baz: 1,
},
})
// expect(extension.options).to.deep.eq({
// baz: 1,
// })
// })
expect(newExtension.options).to.deep.eq({
foo: 1,
bar: 1,
baz: 1,
})
})
it('should be overwritable', () => {
const extension = Extension
.create({
defaultOptions: {
foo: 1,
bar: 1,
},
})
.extend({
defaultOptions: {
baz: 1,
},
})
expect(extension.options).to.deep.eq({
baz: 1,
})
})
})