From b1aa7863e88d4650a933062fdd66c4fe5c90d0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Sat, 17 Apr 2021 21:25:04 +0200 Subject: [PATCH] test: add more extension option tests --- .../integration/core/extensionOptions.spec.ts | 75 ++++++++++++++----- 1 file changed, 56 insertions(+), 19 deletions(-) diff --git a/tests/cypress/integration/core/extensionOptions.spec.ts b/tests/cypress/integration/core/extensionOptions.spec.ts index 87ca6be0..96a05fed 100644 --- a/tests/cypress/integration/core/extensionOptions.spec.ts +++ b/tests/cypress/integration/core/extensionOptions.spec.ts @@ -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, + }) + }) })