From edb08bba4a19cb3651153297bf463080fbdc5a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Mon, 3 May 2021 09:42:01 +0200 Subject: [PATCH] test: add tests for can() method --- tests/cypress/integration/core/can.spec.ts | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/cypress/integration/core/can.spec.ts diff --git a/tests/cypress/integration/core/can.spec.ts b/tests/cypress/integration/core/can.spec.ts new file mode 100644 index 00000000..f5194bcf --- /dev/null +++ b/tests/cypress/integration/core/can.spec.ts @@ -0,0 +1,73 @@ +/// + +import { Editor } from '@tiptap/core' +import Document from '@tiptap/extension-document' +import Paragraph from '@tiptap/extension-paragraph' +import Text from '@tiptap/extension-text' +import History from '@tiptap/extension-history' + +describe('can', () => { + it('not undo', () => { + const editor = new Editor({ + extensions: [ + Document, + Paragraph, + Text, + History, + ], + }) + + const canUndo = editor.can().undo() + + expect(canUndo).to.eq(false) + }) + + it('undo', () => { + const editor = new Editor({ + extensions: [ + Document, + Paragraph, + Text, + History, + ], + }) + + editor.commands.setContent('foo') + + const canUndo = editor.can().undo() + + expect(canUndo).to.eq(true) + }) + + it('not chain undo', () => { + const editor = new Editor({ + extensions: [ + Document, + Paragraph, + Text, + History, + ], + }) + + const canUndo = editor.can().chain().undo().run() + + expect(canUndo).to.eq(false) + }) + + it('chain undo', () => { + const editor = new Editor({ + extensions: [ + Document, + Paragraph, + Text, + History, + ], + }) + + editor.commands.setContent('foo') + + const canUndo = editor.can().chain().undo().run() + + expect(canUndo).to.eq(true) + }) +})