1
1
/* eslint no-undef: "off" */
2
+ const assert = require ( 'assert' ) . strict
2
3
const SmartApp = require ( '../lib/smart-app' )
3
4
4
5
describe ( 'smartapp-page-spec' , ( ) => {
@@ -39,7 +40,7 @@ describe('smartapp-page-spec', () => {
39
40
settings : { }
40
41
} )
41
42
42
- const pageReponse = app . handleMockCallback ( {
43
+ const pageResponse = app . handleMockCallback ( {
43
44
lifecycle : 'CONFIGURATION' ,
44
45
executionId : 'abcf6e72-60f4-1f27-341b-449ad9e2192e' ,
45
46
locale : 'en' ,
@@ -59,8 +60,66 @@ describe('smartapp-page-spec', () => {
59
60
settings : { }
60
61
} )
61
62
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 )
64
123
} )
65
124
66
125
it ( 'should configure event logger' , ( ) => {
0 commit comments