@@ -164,3 +164,169 @@ describe('Template: default', () => {
164
164
cy . contains ( 'created()' ) . should ( 'not.exist' ) ;
165
165
} ) ;
166
166
} ) ;
167
+
168
+ describe ( 'Template JS: default' , ( ) => {
169
+ /* eslint-disable newline-per-chained-call */
170
+ before ( ( ) => {
171
+ cy . visit ( '/../../../example/docs/module-CounterJS.html' ) ;
172
+ cy . screenshot ( ) ;
173
+ } ) ;
174
+
175
+ it ( 'should renders module name correctly' , ( ) => {
176
+ cy
177
+ . get ( '.page-title' )
178
+ . contains ( 'Module: CounterJS' ) ;
179
+
180
+ cy
181
+ . get ( 'nav a[href="module-CounterJS.html"]' )
182
+ . contains ( 'CounterJS' ) ;
183
+ } ) ;
184
+
185
+ it ( 'should renders props correctly' , ( ) => {
186
+ const props = [
187
+ {
188
+ name : '<code>initialCounter</code>' ,
189
+ type : 'Number' ,
190
+ defaultValue : '-' ,
191
+ required : '<b>Yes</b>' ,
192
+ description : '-' ,
193
+ } ,
194
+ {
195
+ name : '<code>step</code>' ,
196
+ type : 'Number' ,
197
+ defaultValue : '<code>1</code>' ,
198
+ required : 'No' ,
199
+ description : 'Step' ,
200
+ } ,
201
+ ] ;
202
+
203
+ cy . get ( '[data-jsdoc-vuejs="section-props"]' ) . contains ( 'Props' ) ;
204
+ cy . get ( '[data-jsdoc-vuejs="table-props"]' ) . as ( 'table-props' ) ;
205
+
206
+ cy
207
+ . get ( '@table-props' )
208
+ . find ( '> thead > tr > th' )
209
+ . contains ( 'Name' )
210
+ . next ( ) . contains ( 'Type' )
211
+ . next ( ) . contains ( 'Default value' )
212
+ . next ( ) . contains ( 'Required?' )
213
+ . next ( ) . contains ( 'Description' ) ;
214
+
215
+ cy
216
+ . get ( '@table-props' )
217
+ . find ( '> tbody > tr' )
218
+ . then ( ( $rows ) => {
219
+ expect ( $rows ) . to . have . length ( 2 ) ;
220
+
221
+ props . forEach ( ( prop , i ) => {
222
+ const $row = $rows . eq ( i ) ;
223
+ const $children = $row . children ( ) ;
224
+
225
+ expect ( $children . eq ( 0 ) . html ( ) ) . to . eq ( prop . name ) ;
226
+ expect ( $children . eq ( 1 ) . html ( ) ) . to . eq ( prop . type ) ;
227
+ expect ( $children . eq ( 2 ) . html ( ) ) . to . eq ( prop . defaultValue ) ;
228
+ expect ( $children . eq ( 3 ) . html ( ) ) . to . eq ( prop . required ) ;
229
+ expect ( $children . eq ( 4 ) . html ( ) ) . to . eq ( prop . description ) ;
230
+ } ) ;
231
+ } ) ;
232
+ } ) ;
233
+
234
+ it ( 'should renders data correctly' , ( ) => {
235
+ const data = [
236
+ {
237
+ name : '<code>counter</code>' ,
238
+ type : 'Number' ,
239
+ defaultValue : '-' ,
240
+ description : "Current counter's value" ,
241
+ } ,
242
+ ] ;
243
+
244
+ cy . get ( '[data-jsdoc-vuejs="section-data"]' ) . contains ( 'Data' ) ;
245
+ cy . get ( '[data-jsdoc-vuejs="table-data"]' ) . as ( 'table-data' ) ;
246
+
247
+ cy
248
+ . get ( '@table-data' )
249
+ . find ( '> thead > tr > th' )
250
+ . contains ( 'Name' )
251
+ . next ( ) . contains ( 'Type' )
252
+ . next ( ) . contains ( 'Default value' )
253
+ . next ( ) . contains ( 'Description' ) ;
254
+
255
+ cy
256
+ . get ( '@table-data' )
257
+ . find ( '> tbody > tr' )
258
+ . then ( ( $rows ) => {
259
+ expect ( $rows ) . to . have . length ( 1 ) ;
260
+
261
+ data . forEach ( ( d , i ) => {
262
+ const $row = $rows . eq ( i ) ;
263
+ const $children = $row . children ( ) ;
264
+
265
+ expect ( $children . eq ( 0 ) . html ( ) ) . to . eq ( d . name ) ;
266
+ expect ( $children . eq ( 1 ) . html ( ) ) . to . eq ( d . type ) ;
267
+ expect ( $children . eq ( 2 ) . html ( ) ) . to . eq ( d . defaultValue ) ;
268
+ expect ( $children . eq ( 3 ) . html ( ) ) . to . eq ( d . description ) ;
269
+ } ) ;
270
+ } ) ;
271
+ } ) ;
272
+
273
+ it ( 'should renders computed correctly' , ( ) => {
274
+ const computeds = [
275
+ { name : '<code>fooList</code>' , type : 'Array.<String>' , description : 'A list of foo' } ,
276
+ { name : '<code>barList</code>' , type : 'Array.<String>' , description : 'A list of bar' } ,
277
+ { name : '<code>message</code>' , type : 'String' , description : 'A message' } ,
278
+ ] ;
279
+
280
+ cy . get ( '[data-jsdoc-vuejs="section-computed"]' ) . contains ( 'Computed' ) ;
281
+ cy . get ( '[data-jsdoc-vuejs="table-computed"]' ) . as ( 'table-computed' ) ;
282
+
283
+ cy
284
+ . get ( '@table-computed' )
285
+ . find ( '> thead > tr > th' )
286
+ . contains ( 'Name' )
287
+ . next ( ) . contains ( 'Type' )
288
+ . next ( ) . contains ( 'Description' ) ;
289
+
290
+ cy
291
+ . get ( '@table-computed' )
292
+ . find ( '> tbody > tr' )
293
+ . then ( ( $rows ) => {
294
+ expect ( $rows ) . to . have . length ( 3 ) ;
295
+
296
+ computeds . forEach ( ( computed , i ) => {
297
+ const $row = $rows . eq ( i ) ;
298
+ const $children = $row . children ( ) ;
299
+
300
+ expect ( $children . eq ( 0 ) . html ( ) ) . to . eq ( computed . name ) ;
301
+ expect ( $children . eq ( 1 ) . html ( ) ) . to . eq ( computed . type ) ;
302
+ expect ( $children . eq ( 2 ) . html ( ) ) . to . eq ( computed . description ) ;
303
+ } ) ;
304
+ } ) ;
305
+ } ) ;
306
+
307
+ it ( 'should render methods properly' , ( ) => {
308
+ cy . contains ( 'h3' , 'Methods' ) . should ( 'have.attr' , 'class' , 'subsection-title' ) ;
309
+
310
+ cy . get ( '#decrement' )
311
+ . contains ( 'decrement()' )
312
+ . next ( '.description' )
313
+ . next ( '.details' )
314
+ . contains ( 'a[href="js_CounterJS.js.html#line43"]' , 'line 43' ) ;
315
+
316
+ cy . get ( '#increment' )
317
+ . contains ( 'increment()' )
318
+ . next ( '.description' )
319
+ . next ( '.details' )
320
+ . contains ( 'a[href="js_CounterJS.js.html#line36"]' , 'line 36' ) ;
321
+
322
+ cy . get ( '#showDialog' )
323
+ . contains ( 'showDialog(counter)' )
324
+ . next ( '.description' )
325
+ . next ( 'h5' )
326
+ . next ( '.params' )
327
+ . next ( '.details' )
328
+ . contains ( 'a[href="js_CounterJS.js.html#line51"]' , 'line 51' ) ;
329
+
330
+ cy . contains ( 'created()' ) . should ( 'not.exist' ) ;
331
+ } ) ;
332
+ } ) ;
0 commit comments