11/* eslint no-undef: "off" */
2+ const assert = require ( 'assert' ) . strict
23const SmartApp = require ( '../lib/smart-app' )
34
45describe ( 'smartapp-page-spec' , ( ) => {
@@ -39,7 +40,7 @@ describe('smartapp-page-spec', () => {
3940 settings : { }
4041 } )
4142
42- const pageReponse = app . handleMockCallback ( {
43+ const pageResponse = app . handleMockCallback ( {
4344 lifecycle : 'CONFIGURATION' ,
4445 executionId : 'abcf6e72-60f4-1f27-341b-449ad9e2192e' ,
4546 locale : 'en' ,
@@ -59,8 +60,66 @@ describe('smartapp-page-spec', () => {
5960 settings : { }
6061 } )
6162
62- console . log ( JSON . stringify ( initResponse , null , 2 ) )
63- console . log ( JSON . stringify ( pageReponse , null , 2 ) )
63+ const expectedInitResponse = { initialize : {
64+ id : 'xxx' ,
65+ firstPageId : 'eaMainPage' ,
66+ permissions : [ ] ,
67+ disableCustomDisplayName : false ,
68+ disableRemoveApp : false
69+ } }
70+
71+ const expectedPageResponse = {
72+ page : {
73+ name : 'pages.eaMainPage.name' ,
74+ complete : true ,
75+ pageId : 'eaMainPage' ,
76+ nextPageId : null ,
77+ previousPageId : null ,
78+ sections : [
79+ {
80+ name : 'whenDoorOpensAndCloses' ,
81+ settings : [
82+ {
83+ id : 'contactSensor' ,
84+ name : 'pages.eaMainPage.settings.contactSensor.name' ,
85+ required : true ,
86+ type : 'DEVICE' ,
87+ description : 'Tap to set' ,
88+ multiple : false ,
89+ capabilities : [
90+ 'contactSensor'
91+ ] ,
92+ permissions : [
93+ 'r'
94+ ]
95+ }
96+ ]
97+ } ,
98+ {
99+ name : 'turnLightsOnAndOff' ,
100+ settings : [
101+ {
102+ id : 'lights' ,
103+ name : 'pages.eaMainPage.settings.lights.name' ,
104+ required : true ,
105+ type : 'DEVICE' ,
106+ description : 'Tap to set' ,
107+ multiple : true ,
108+ capabilities : [
109+ 'switch'
110+ ] ,
111+ permissions : [
112+ 'r' ,
113+ 'x'
114+ ]
115+ }
116+ ]
117+ }
118+ ]
119+ }
120+ }
121+ assert . deepStrictEqual ( initResponse . configurationData , expectedInitResponse )
122+ assert . deepStrictEqual ( pageResponse . configurationData , expectedPageResponse )
64123 } )
65124
66125 it ( 'should configure event logger' , ( ) => {
0 commit comments