From db69652c920915746925a3e2d1fd91f95f3521d2 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Sun, 12 Jun 2022 17:34:26 +0800 Subject: [PATCH] test:add word count test case --- cypress/integration/editor.spec.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cypress/integration/editor.spec.ts b/cypress/integration/editor.spec.ts index 12d1abe..1c77356 100644 --- a/cypress/integration/editor.spec.ts +++ b/cypress/integration/editor.spec.ts @@ -24,7 +24,6 @@ describe('基础功能', () => { cy.get('@canvas').type(`{ctrl}s`) }) - }) it('模式切换', () => { @@ -39,11 +38,9 @@ describe('基础功能', () => { cy.get('@canvas').click() cy.get('.cursor').should('have.css', 'display', 'none') - }) it('页面缩放', () => { - cy.get('.page-scale-add').click() cy.get('.page-scale-percentage').contains('110%') @@ -51,7 +48,24 @@ describe('基础功能', () => { cy.get('.page-scale-minus').click().click() cy.get('.page-scale-percentage').contains('90%') + }) + it('字数统计', () => { + cy.getEditor().then((editor: Editor) => { + editor.listener.contentChange = async function () { + const wordCount = await editor.command.getWordCount() + + expect(7).to.be.eq(wordCount) + } + + editor.command.executeSelectAll() + + editor.command.executeBackspace() + + editor.command.executeInsertElementList([{ + value: 'canvas-editor 2022 编辑器' + }]) + }) }) })