mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-30 04:57:50 +08:00
8c6751f0c6
* chore: add precommit hook for eslint fixes, fix linting issues * chore: add eslint import sort plugin
74 lines
1.3 KiB
TypeScript
74 lines
1.3 KiB
TypeScript
/// <reference types="cypress" />
|
|
|
|
import { Editor } from '@tiptap/core'
|
|
import Document from '@tiptap/extension-document'
|
|
import History from '@tiptap/extension-history'
|
|
import Paragraph from '@tiptap/extension-paragraph'
|
|
import Text from '@tiptap/extension-text'
|
|
|
|
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)
|
|
})
|
|
})
|