@@ -91,7 +91,70 @@ describe('Stack api Test', () => {
91
91
. catch ( done )
92
92
} )
93
93
94
- it ( 'should add stack settings' , done => {
94
+ it ( 'should set stack_variables correctly' , done => {
95
+ const variables = {
96
+ stack_variables : {
97
+ enforce_unique_urls : true ,
98
+ sys_rte_allowed_tags : 'style,figure,script' ,
99
+ sys_rte_skip_format_on_paste : 'GD:font-size' ,
100
+ samplevariable : 'too'
101
+ }
102
+ }
103
+
104
+ client . stack ( { api_key : stacks . api_key } )
105
+ . addSettings ( variables )
106
+ . then ( ( response ) => {
107
+ const vars = response . stack_variables
108
+ expect ( vars . enforce_unique_urls ) . to . equal ( true )
109
+ expect ( vars . sys_rte_allowed_tags ) . to . equal ( 'style,figure,script' )
110
+ expect ( vars . sys_rte_skip_format_on_paste ) . to . equal ( 'GD:font-size' )
111
+ expect ( vars . samplevariable ) . to . equal ( 'too' )
112
+ done ( )
113
+ } )
114
+ . catch ( done )
115
+ } )
116
+
117
+ it ( 'should set rte settings correctly' , done => {
118
+ const variables = {
119
+ rte : {
120
+ cs_breakline_on_enter : true ,
121
+ cs_only_breakline : true
122
+ }
123
+ }
124
+
125
+ client . stack ( { api_key : stacks . api_key } )
126
+ . addSettings ( variables )
127
+ . then ( ( response ) => {
128
+ const rte = response . rte
129
+ expect ( rte . cs_breakline_on_enter ) . to . equal ( true )
130
+ expect ( rte . cs_only_breakline ) . to . equal ( true )
131
+ done ( )
132
+ } )
133
+ . catch ( done )
134
+ } )
135
+
136
+ it ( 'should set live_preview settings correctly' , done => {
137
+ const variables = {
138
+ live_preview : {
139
+ enabled : true ,
140
+ 'default-env' : '' ,
141
+ 'default-url' : 'https://preview.example.com'
142
+ }
143
+ }
144
+
145
+ client . stack ( { api_key : stacks . api_key } )
146
+ . addSettings ( variables )
147
+ . then ( ( response ) => {
148
+ const preview = response . live_preview
149
+ expect ( preview . enabled ) . to . equal ( true )
150
+ expect ( preview [ 'default-env' ] ) . to . equal ( '' )
151
+ expect ( preview [ 'default-url' ] ) . to . equal ( 'https://preview.example.com' )
152
+ done ( )
153
+ } )
154
+ . catch ( done )
155
+ } )
156
+
157
+ it ( 'should add simple stack variable' , done => {
95
158
client . stack ( { api_key : stacks . api_key } )
96
159
. addSettings ( { samplevariable : 'too' } )
97
160
. then ( ( response ) => {
@@ -101,6 +164,47 @@ describe('Stack api Test', () => {
101
164
. catch ( done )
102
165
} )
103
166
167
+ it ( 'should add stack settings' , done => {
168
+ const variables = {
169
+ stack_variables : {
170
+ enforce_unique_urls : true ,
171
+ sys_rte_allowed_tags : 'style,figure,script' ,
172
+ sys_rte_skip_format_on_paste : 'GD:font-size' ,
173
+ samplevariable : 'too'
174
+ } ,
175
+ rte : {
176
+ cs_breakline_on_enter : true ,
177
+ cs_only_breakline : true
178
+ } ,
179
+ live_preview : {
180
+ enabled : true ,
181
+ 'default-env' : '' ,
182
+ 'default-url' : 'https://preview.example.com'
183
+ }
184
+ }
185
+
186
+ client . stack ( { api_key : stacks . api_key } )
187
+ . addSettings ( variables ) . then ( ( response ) => {
188
+ const vars = response . stack_variables
189
+ expect ( vars . enforce_unique_urls ) . to . equal ( true , 'enforce_unique_urls must be true' )
190
+ expect ( vars . sys_rte_allowed_tags ) . to . equal ( 'style,figure,script' , 'sys_rte_allowed_tags must match' )
191
+ expect ( vars . sys_rte_skip_format_on_paste ) . to . equal ( 'GD:font-size' , 'sys_rte_skip_format_on_paste must match' )
192
+ expect ( vars . samplevariable ) . to . equal ( 'too' , 'samplevariable must be "too"' )
193
+
194
+ const rte = response . rte
195
+ expect ( rte . cs_breakline_on_enter ) . to . equal ( true , 'cs_breakline_on_enter must be true' )
196
+ expect ( rte . cs_only_breakline ) . to . equal ( true , 'cs_only_breakline must be true' )
197
+
198
+ const preview = response . live_preview
199
+ expect ( preview . enabled ) . to . equal ( true , 'live_preview.enabled must be true' )
200
+ expect ( preview [ 'default-env' ] ) . to . equal ( '' , 'default-env must match' )
201
+ expect ( preview [ 'default-url' ] ) . to . equal ( 'https://preview.example.com' , 'default-url must match' )
202
+
203
+ done ( )
204
+ } )
205
+ . catch ( done )
206
+ } )
207
+
104
208
it ( 'should reset stack settings' , done => {
105
209
client . stack ( { api_key : stacks . api_key } )
106
210
. resetSettings ( )
0 commit comments