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