@@ -4,38 +4,23 @@ import { OscdWizards } from '@openscd/open-scd/src/addons/Wizards';
44
55import { editLN0Wizard } from '../../../src/wizards/ln0.js' ;
66import { WizardInputElement } from '@openscd/open-scd/src/foundation.js' ;
7- import { fetchDoc , setWizardTextFieldValue } from './test-support.js' ;
7+ import { fetchDoc } from './test-support.js' ;
88import { WizardTextField } from '@openscd/open-scd/src/wizard-textfield.js' ;
99
10-
11-
1210describe ( 'ln0 wizards' , ( ) => {
1311 let doc : XMLDocument ;
1412 let element : OscdWizards ;
1513 let inputs : WizardInputElement [ ] ;
14+ let ln : Element ;
1615
17- const values = {
18- lnType : 'LN0-type' ,
19- desc : 'LN0-description' ,
20- lnClass : 'LN0-class' ,
21- inst : '1' ,
22- } ;
23- const readonlyFields = [
24- 'lnType' ,
25- 'lnClass' ,
26- 'inst'
27- ] ;
28-
29- const ln = < Element > (
30- new DOMParser ( ) . parseFromString (
31- `<LN0 desc="${ values . desc } " lnType="${ values . lnType } " inst="${ values . inst } " lnClass="${ values . lnClass } "></LN0>` ,
32- 'application/xml'
33- ) . documentElement
34- ) ;
16+ const readonlyFields = [ 'lnClass' , 'inst' ] ;
3517
3618 beforeEach ( async ( ) => {
3719 doc = await fetchDoc ( '/test/testfiles/wizards/ied.scd' ) ;
3820
21+ ln = doc . querySelector ( 'LN0' ) ! ;
22+ expect ( ln ) . to . exist ;
23+
3924 element = await fixture (
4025 html `< oscd-wizards .host =${ document } > </ oscd-wizards > `
4126 ) ;
@@ -46,20 +31,36 @@ describe('ln0 wizards', () => {
4631 inputs = Array . from ( element . wizardUI . inputs ) ;
4732 } ) ;
4833
49- Object . entries ( values ) . forEach ( ( [ key , value ] ) => {
50- it ( `contains a wizard-textfield with a non-empty "${ key } " value` , async ( ) => {
51- expect (
52- ( < WizardInputElement [ ] > inputs ) . find (
53- ( textField ) => textField . label === key
54- ) ?. value
55- ) . to . equal ( value ) ;
34+ it ( 'contains a wizard-select for lnType with available LNodeTypes' , async ( ) => {
35+ const lnTypeInput = ( < WizardInputElement [ ] > inputs ) . find (
36+ input => input . label === 'lnType'
37+ ) ;
38+ expect ( lnTypeInput ) . to . exist ;
39+ expect ( lnTypeInput ?. tagName ) . to . equal ( 'WIZARD-SELECT' ) ;
40+ } ) ;
41+
42+ it ( 'lnType select contains LNodeType options with lnClass="LLN0"' , async ( ) => {
43+ const lnTypeSelect = ( < WizardInputElement [ ] > inputs ) . find (
44+ input => input . label === 'lnType'
45+ ) ;
46+ const options = lnTypeSelect ?. querySelectorAll ( 'mwc-list-item' ) ;
47+ expect ( options ) . to . have . length . greaterThan ( 0 ) ;
48+
49+ const lln0Types = doc . querySelectorAll ( 'LNodeType[lnClass="LLN0"]' ) ;
50+ expect ( options ) . to . have . lengthOf ( lln0Types . length ) ;
51+ } ) ;
52+
53+ it ( 'contains required fields' , async ( ) => {
54+ [ 'lnType' , 'lnClass' ] . forEach ( field => {
55+ const input = ( < WizardInputElement [ ] > inputs ) . find ( i => i . label === field ) ;
56+ expect ( input ) . to . exist ;
5657 } ) ;
5758 } ) ;
5859
59- readonlyFields . forEach ( ( field ) => {
60+ readonlyFields . forEach ( field => {
6061 it ( `is a readonly field ${ field } ` , async ( ) => {
6162 const input = ( < WizardInputElement [ ] > inputs ) . find (
62- ( textField ) => textField . label === field
63+ textField => textField . label === field
6364 ) as WizardTextField ;
6465
6566 expect ( input . readOnly ) . to . be . true ;
0 commit comments