From 21de02f09361299adccf8d4c3b6286cbe03c5603 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Fri, 15 Apr 2022 21:50:35 +0800 Subject: [PATCH] feat:add checkbox control test case --- cypress/integration/control/checkbox.spec.ts | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 cypress/integration/control/checkbox.spec.ts diff --git a/cypress/integration/control/checkbox.spec.ts b/cypress/integration/control/checkbox.spec.ts new file mode 100644 index 0000000..f7d43cd --- /dev/null +++ b/cypress/integration/control/checkbox.spec.ts @@ -0,0 +1,47 @@ +import Editor, { ControlType, ElementType } from '../../../src/editor' + +describe('控件-复选框', () => { + + beforeEach(() => { + cy.visit('http://localhost:3000/canvas-editor/') + + cy.get('canvas').first().as('canvas').should('have.length', 1) + }) + + const elementType: ElementType = 'control' + const controlType: ControlType = 'checkbox' + + it('复选框', () => { + cy.getEditor().then((editor: Editor) => { + editor.listener.saved = function (payload) { + const data = payload.data[0] + + expect(data.control!.code).to.be.eq('98175') + } + + editor.command.executeSelectAll() + + editor.command.executeBackspace() + + editor.command.executeInsertElementList([{ + type: elementType, + value: '', + control: { + code: '98175', + type: controlType, + value: null, + valueSets: [{ + value: '有', + code: '98175' + }, { + value: '无', + code: '98176' + }] + } + }]) + + cy.get('@canvas').type('{ctrl}s') + }) + }) + +})