@@ -13,7 +13,7 @@ describe('pagebuilder', () => {
13
13
14
14
it ( 'should process one section' , ( ) => {
15
15
const page = new Page ( 'mainPage' )
16
-
16
+ page . defaultRequired ( true )
17
17
page . section ( 'When this door opens and closes' , section => {
18
18
section . deviceSetting ( 'contactSensor' )
19
19
. capabilities ( [ 'contactSensor' ] )
@@ -37,7 +37,7 @@ describe('pagebuilder', () => {
37
37
38
38
it ( 'should process two sections' , ( ) => {
39
39
const page = new Page ( 'mainPage' )
40
-
40
+ page . defaultRequired ( true )
41
41
page . section ( 'When this door opens and closes' , section => {
42
42
section . deviceSetting ( 'contactSensor' )
43
43
. capabilities ( [ 'contactSensor' ] )
@@ -82,7 +82,7 @@ describe('pagebuilder', () => {
82
82
83
83
it ( 'should process unnamed section' , ( ) => {
84
84
const page = new Page ( 'mainPage' )
85
-
85
+ page . defaultRequired ( true )
86
86
page . section ( section => {
87
87
section . deviceSetting ( 'contactSensor' )
88
88
. capabilities ( [ 'contactSensor' ] )
@@ -125,10 +125,8 @@ describe('pagebuilder', () => {
125
125
126
126
it ( 'should honor default required' , ( ) => {
127
127
const page = new Page ( 'mainPage' )
128
- page . defaultRequired ( false )
129
-
128
+ page . defaultRequired ( true )
130
129
page . section ( 'When this door opens and closes' , section => {
131
- section . defaultRequired ( true )
132
130
section . deviceSetting ( 'contactSensor' )
133
131
. capabilities ( [ 'contactSensor' ] )
134
132
. name ( 'Select an open/close sensor' )
@@ -150,7 +148,7 @@ describe('pagebuilder', () => {
150
148
// Console.log(JSON.stringify(json, null, 2))
151
149
expect ( json . sections [ 0 ] . settings [ 0 ] . required ) . to . equal ( true )
152
150
expect ( json . sections [ 0 ] . settings [ 1 ] . required ) . to . equal ( false )
153
- expect ( json . sections [ 1 ] . settings [ 0 ] . required ) . to . equal ( false )
151
+ expect ( json . sections [ 1 ] . settings [ 0 ] . required ) . to . equal ( true )
154
152
} )
155
153
156
154
it ( 'options formats' , ( ) => {
@@ -199,4 +197,16 @@ describe('pagebuilder', () => {
199
197
expect ( json . sections [ 0 ] . settings [ 0 ] . page ) . to . equal ( 'anotherPage' )
200
198
expect ( json . sections [ 0 ] . settings [ 0 ] . required ) . to . equal ( undefined )
201
199
} )
200
+
201
+ it ( 'page defaultRequired adds required:true' , ( ) => {
202
+ const page = new Page ( 'mainPage' )
203
+ page . defaultRequired ( true )
204
+ page . section ( section => {
205
+ section . paragraphSetting ( 'mainParagraph' )
206
+ } )
207
+
208
+ const json = page . toJson ( )
209
+ // Console.log(JSON.stringify(json, null, 2))
210
+ expect ( json . sections [ 0 ] . settings [ 0 ] . required ) . to . equal ( true )
211
+ } )
202
212
} )
0 commit comments