From 90b2061c3837c79ae7874c2a474b70a0acbe7f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Wed, 16 Mar 2022 18:16:47 +0800 Subject: [PATCH] feat:add format test case --- cypress/integration/menus/format.spec.ts | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 cypress/integration/menus/format.spec.ts 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') + }) + }) + }) + +})