@@ -13,7 +13,7 @@ describe('pagebuilder', () => {
1313
1414 it ( 'should process one section' , ( ) => {
1515 const page = new Page ( 'mainPage' )
16-
16+ page . defaultRequired ( true )
1717 page . section ( 'When this door opens and closes' , section => {
1818 section . deviceSetting ( 'contactSensor' )
1919 . capabilities ( [ 'contactSensor' ] )
@@ -37,7 +37,7 @@ describe('pagebuilder', () => {
3737
3838 it ( 'should process two sections' , ( ) => {
3939 const page = new Page ( 'mainPage' )
40-
40+ page . defaultRequired ( true )
4141 page . section ( 'When this door opens and closes' , section => {
4242 section . deviceSetting ( 'contactSensor' )
4343 . capabilities ( [ 'contactSensor' ] )
@@ -82,7 +82,7 @@ describe('pagebuilder', () => {
8282
8383 it ( 'should process unnamed section' , ( ) => {
8484 const page = new Page ( 'mainPage' )
85-
85+ page . defaultRequired ( true )
8686 page . section ( section => {
8787 section . deviceSetting ( 'contactSensor' )
8888 . capabilities ( [ 'contactSensor' ] )
@@ -125,10 +125,8 @@ describe('pagebuilder', () => {
125125
126126 it ( 'should honor default required' , ( ) => {
127127 const page = new Page ( 'mainPage' )
128- page . defaultRequired ( false )
129-
128+ page . defaultRequired ( true )
130129 page . section ( 'When this door opens and closes' , section => {
131- section . defaultRequired ( true )
132130 section . deviceSetting ( 'contactSensor' )
133131 . capabilities ( [ 'contactSensor' ] )
134132 . name ( 'Select an open/close sensor' )
@@ -150,7 +148,7 @@ describe('pagebuilder', () => {
150148 // Console.log(JSON.stringify(json, null, 2))
151149 expect ( json . sections [ 0 ] . settings [ 0 ] . required ) . to . equal ( true )
152150 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 )
154152 } )
155153
156154 it ( 'options formats' , ( ) => {
@@ -199,4 +197,16 @@ describe('pagebuilder', () => {
199197 expect ( json . sections [ 0 ] . settings [ 0 ] . page ) . to . equal ( 'anotherPage' )
200198 expect ( json . sections [ 0 ] . settings [ 0 ] . required ) . to . equal ( undefined )
201199 } )
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+ } )
202212} )
0 commit comments