diff --git a/cypress/integration/menus/format.spec.ts b/cypress/integration/menus/format.spec.ts new file mode 100644 index 0000000..6b9580f --- /dev/null +++ b/cypress/integration/menus/format.spec.ts @@ -0,0 +1,44 @@ +import Editor from '../../../src/editor' + +describe('菜单-清除格式', () => { + + beforeEach(() => { + cy.visit('http://localhost:3000/canvas-editor/') + + cy.get('canvas').first().as('canvas').should('have.length', 1) + }) + + const text = 'canvas-editor' + const textLength = text.length + + it('清除格式', () => { + cy.getEditor().then((editor: Editor) => { + editor.listener.saved = function (payload) { + const data = payload.data + + expect(data[0].italic).to.eq(false) + + expect(data[0].bold).to.eq(false) + } + + editor.command.executeSelectAll() + + editor.command.executeBackspace() + + editor.command.executeInsertElementList([{ + value: text, + bold: true, + italic: true + }]) + + editor.command.executeSetRange(0, textLength) + + cy.get('.menu-item__format') + .click() + .then(() => { + cy.get('@canvas').type('{ctrl}s') + }) + }) + }) + +})