|
| 1 | +/* eslint-disable no-unused-expressions */ |
| 2 | +import { html, fixture, expect } from '@open-wc/testing'; |
| 3 | +import './function-editor.js'; |
| 4 | +import { testScl } from './scl-bay-template.testfiles.js'; |
| 5 | + |
| 6 | +describe('FunctionEditor', () => { |
| 7 | + let element: any; |
| 8 | + let doc: XMLDocument; |
| 9 | + |
| 10 | + beforeEach(async () => { |
| 11 | + doc = new DOMParser().parseFromString(testScl, 'application/xml'); |
| 12 | + const func = doc.querySelector('Function'); |
| 13 | + element = await fixture( |
| 14 | + html`<compas-function-editor-a1b2c3d4 |
| 15 | + .doc=${doc} |
| 16 | + .function=${func} |
| 17 | + ></compas-function-editor-a1b2c3d4>` |
| 18 | + ); |
| 19 | + await element.updateComplete; |
| 20 | + }); |
| 21 | + |
| 22 | + it('renders the add subfunction dialog and fields', () => { |
| 23 | + element.addSubFunctionDialog.show(); |
| 24 | + expect(element.addSubFunctionDialog.open).to.be.true; |
| 25 | + expect(element.subFunctionNameField).to.exist; |
| 26 | + expect(element.subFunctionDescField).to.exist; |
| 27 | + expect(element.subFunctionTypeField).to.exist; |
| 28 | + }); |
| 29 | + |
| 30 | + it('enforces unique subfunction names', async () => { |
| 31 | + const parent = doc.querySelector('Function'); |
| 32 | + element.subFunctionDialogParent = parent; |
| 33 | + |
| 34 | + element.addSubFunctionDialog.show(); |
| 35 | + element.subFunctionNameField.value = 'General'; |
| 36 | + element.saveSubFunction(); |
| 37 | + await element.updateComplete; |
| 38 | + expect(element.subFunctionNameField.validationMessage).to.match( |
| 39 | + /Name must be unique/i |
| 40 | + ); |
| 41 | + }); |
| 42 | +}); |
0 commit comments