mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
add tests for a few core commands
This commit is contained in:
parent
fa73035aa4
commit
5a1f8d7b6a
36
tests/cypress/integration/core/clearContent.spec.ts
Normal file
36
tests/cypress/integration/core/clearContent.spec.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
import { Editor } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
|
||||
describe('clearContent', () => {
|
||||
it('returns true when clearing the content', () => {
|
||||
const editor = new Editor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
],
|
||||
})
|
||||
|
||||
const command = editor.commands.clearContent()
|
||||
|
||||
expect(command).to.be.true
|
||||
})
|
||||
|
||||
it('clears the content when using clearContent', () => {
|
||||
const editor = new Editor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
],
|
||||
})
|
||||
|
||||
editor.commands.clearContent()
|
||||
|
||||
expect(editor.getHTML()).to.eq('<p></p>')
|
||||
})
|
||||
})
|
36
tests/cypress/integration/core/insertHTML.spec.ts
Normal file
36
tests/cypress/integration/core/insertHTML.spec.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
import { Editor } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
|
||||
describe('insertHTML', () => {
|
||||
it('returns true when inserting HTML', () => {
|
||||
const editor = new Editor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
],
|
||||
})
|
||||
|
||||
const command = editor.commands.insertHTML('<p>Cindy Lauper</p>')
|
||||
|
||||
expect(command).to.be.true
|
||||
})
|
||||
|
||||
it('appends the content when using insertHTML', () => {
|
||||
const editor = new Editor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
],
|
||||
})
|
||||
|
||||
editor.commands.insertHTML('<p>Cindy Lauper</p>')
|
||||
|
||||
expect(editor.getHTML()).to.eq('<p></p><p>Cindy Lauper</p>')
|
||||
})
|
||||
})
|
36
tests/cypress/integration/core/setContent.spec.ts
Normal file
36
tests/cypress/integration/core/setContent.spec.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
import { Editor } from '@tiptap/core'
|
||||
import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
|
||||
describe('setContent', () => {
|
||||
it('returns true when setting the content', () => {
|
||||
const editor = new Editor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
],
|
||||
})
|
||||
|
||||
const command = editor.commands.setContent('<p>Cindy Lauper</p>')
|
||||
|
||||
expect(command).to.be.true
|
||||
})
|
||||
|
||||
it('replaces the content when using setContent', () => {
|
||||
const editor = new Editor({
|
||||
extensions: [
|
||||
Document,
|
||||
Paragraph,
|
||||
Text,
|
||||
],
|
||||
})
|
||||
|
||||
editor.commands.setContent('<p>Cindy Lauper</p>')
|
||||
|
||||
expect(editor.getHTML()).to.eq('<p>Cindy Lauper</p>')
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user