als-document 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/document/document.js +192 -0
- package/document/test.js +678 -0
- package/document.js +375 -145
- package/document.min.js +1 -0
- package/index.js +6 -0
- package/package.json +3 -3
- package/parser/parser.js +92 -43
- package/parser/test.js +7 -7
- package/query/query.js +1 -1
- package/query/readme.md +4 -1
- package/readme.md +253 -59
- package/selector/selector.js +14 -13
- package/test/test.js +3 -1
- package/parser/readme.md +0 -121
- package/selector/readme.md +0 -74
package/document/test.js
ADDED
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
let Test = require('als-test')
|
|
2
|
+
let Document = require('./document')
|
|
3
|
+
const { notEqual, smaller, greater } = require('als-test')
|
|
4
|
+
let {equal} = Test
|
|
5
|
+
|
|
6
|
+
module.exports = new Test('Document tests',[
|
|
7
|
+
{
|
|
8
|
+
title:'Create $',
|
|
9
|
+
result: function({html1}){
|
|
10
|
+
this.vars.$ = new Document(html1)
|
|
11
|
+
this.vars.code1 = /*html*/`<div id="test-id"><span>test</span>Hello world<span>test 2</span></div>`
|
|
12
|
+
return 'Done'
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title:'Check selector',
|
|
17
|
+
expected:14,
|
|
18
|
+
result: function({$}){
|
|
19
|
+
return $.$('div').index
|
|
20
|
+
},
|
|
21
|
+
action:equal
|
|
22
|
+
},
|
|
23
|
+
{title:'Insert tests'},
|
|
24
|
+
{
|
|
25
|
+
title:'insert before',
|
|
26
|
+
expected:'test-id',
|
|
27
|
+
result: function({$,code1}){
|
|
28
|
+
let div = $.$('div')
|
|
29
|
+
div.insert(code1,0)
|
|
30
|
+
return $.$('div').id
|
|
31
|
+
},
|
|
32
|
+
action:equal
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title:'Check if new element, includes it\'s children',
|
|
36
|
+
expected:'Hello world',
|
|
37
|
+
result: function({$}){
|
|
38
|
+
return $.$('div').children[1].text
|
|
39
|
+
},
|
|
40
|
+
action:equal
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
title:'Check if new element, includes it\'s children',
|
|
44
|
+
expected:'test',
|
|
45
|
+
result: function({$}){
|
|
46
|
+
return $.$('div').children[0].innerHTML
|
|
47
|
+
},
|
|
48
|
+
action:equal
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title:'Move existing element',
|
|
52
|
+
expected:'test-id',
|
|
53
|
+
result: function({$}){
|
|
54
|
+
let div = $.$('div')
|
|
55
|
+
let script = $.$('script')
|
|
56
|
+
script.insert(div,0)
|
|
57
|
+
return script.prev.id
|
|
58
|
+
},
|
|
59
|
+
action:equal
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
title:'Insert after',
|
|
63
|
+
expected:'test-id',
|
|
64
|
+
result: function({$}){
|
|
65
|
+
let div = $.$('div')
|
|
66
|
+
let script = $.$('script')
|
|
67
|
+
script.insert(div,3)
|
|
68
|
+
return script.next.id
|
|
69
|
+
},
|
|
70
|
+
action:equal
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title:'Insert as first child',
|
|
74
|
+
expected:'script',
|
|
75
|
+
result: function({$}){
|
|
76
|
+
let script = $.$('script')
|
|
77
|
+
let div = $.$('div')
|
|
78
|
+
div.insert(script,1)
|
|
79
|
+
return div.children[0].tag
|
|
80
|
+
},
|
|
81
|
+
action:equal
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title:'Insert as last child',
|
|
85
|
+
expected:'script',
|
|
86
|
+
result: function({$}){
|
|
87
|
+
let span = $.$('span')
|
|
88
|
+
let script = $.$('script')
|
|
89
|
+
span.insert(script,2)
|
|
90
|
+
return span.children[1].tag
|
|
91
|
+
},
|
|
92
|
+
action:equal
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title:'setter before - number of parent children',
|
|
96
|
+
expected:function({$}) {
|
|
97
|
+
return $.$('.headers').children.length
|
|
98
|
+
},
|
|
99
|
+
result:function({$}) {
|
|
100
|
+
$.$('.headers>label').before = '<div id="test1">Test</div>'
|
|
101
|
+
return $.$('.headers').children.length
|
|
102
|
+
},
|
|
103
|
+
action:smaller
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title:'setter before - index of element',
|
|
107
|
+
expected:function({$}) {
|
|
108
|
+
return $.$('.headers').index
|
|
109
|
+
},
|
|
110
|
+
result:function({$}) {
|
|
111
|
+
let el = $.$('.headers')
|
|
112
|
+
let next = el.next
|
|
113
|
+
el.before = next
|
|
114
|
+
return el.prev.index
|
|
115
|
+
},
|
|
116
|
+
action:equal
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
title:'setter after - number of parent children',
|
|
120
|
+
expected:function({$}) {
|
|
121
|
+
return $.$('.headers').children.length
|
|
122
|
+
},
|
|
123
|
+
result:function({$}) {
|
|
124
|
+
$.$('.headers>label').after = '<div id="test2">Test</div>'
|
|
125
|
+
return $.$('.headers').children.length
|
|
126
|
+
},
|
|
127
|
+
action:smaller
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
title:'setter after - index of element',
|
|
131
|
+
expected:function({$}) {
|
|
132
|
+
return $.$('.headers').endIndex+1
|
|
133
|
+
},
|
|
134
|
+
result:function({$}) {
|
|
135
|
+
let el = $.$('.headers')
|
|
136
|
+
let el2 = el.prev
|
|
137
|
+
el.after = el2
|
|
138
|
+
return el2.index + el2.elements.length
|
|
139
|
+
},
|
|
140
|
+
action:equal
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
title:'first - childIndex',
|
|
144
|
+
expected:0,
|
|
145
|
+
result:function({$}) {
|
|
146
|
+
let tabs = $.$('.tabs')
|
|
147
|
+
let child = tabs.children[1]
|
|
148
|
+
tabs.first = child
|
|
149
|
+
return child.childIndex
|
|
150
|
+
},
|
|
151
|
+
action:equal
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title:'first - index',
|
|
155
|
+
expected:function({$}) {
|
|
156
|
+
return $.$('.tabs').children[0].index
|
|
157
|
+
},
|
|
158
|
+
result:function({$}) {
|
|
159
|
+
let tabs = $.$('.tabs')
|
|
160
|
+
let child = tabs.children[2]
|
|
161
|
+
tabs.first = child
|
|
162
|
+
return child.index
|
|
163
|
+
},
|
|
164
|
+
action:equal
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
title:'last - childIndex',
|
|
168
|
+
expected:function({$}){
|
|
169
|
+
let tabs = $.$('.tabs')
|
|
170
|
+
let last = tabs.children.length-1
|
|
171
|
+
return tabs.children[last].childIndex
|
|
172
|
+
},
|
|
173
|
+
result:function({$}) {
|
|
174
|
+
let tabs = $.$('.tabs')
|
|
175
|
+
let child = tabs.children[0]
|
|
176
|
+
tabs.last = child
|
|
177
|
+
return child.childIndex
|
|
178
|
+
},
|
|
179
|
+
action:equal
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
title:'last - index',
|
|
183
|
+
expected:function({$}) {
|
|
184
|
+
let tabs = $.$('.tabs')
|
|
185
|
+
let last = tabs.children.length-1
|
|
186
|
+
return tabs.children[last].index
|
|
187
|
+
},
|
|
188
|
+
result:function({$}) {
|
|
189
|
+
let tabs = $.$('.tabs')
|
|
190
|
+
let child = tabs.children[0]
|
|
191
|
+
let gap = child.elements.length
|
|
192
|
+
tabs.last = child
|
|
193
|
+
return child.index-gap
|
|
194
|
+
},
|
|
195
|
+
action:equal
|
|
196
|
+
},
|
|
197
|
+
{title:'Attributes action tests'},
|
|
198
|
+
{
|
|
199
|
+
title:'Get element\'s style property',
|
|
200
|
+
expected:'none',
|
|
201
|
+
result:function({$}){
|
|
202
|
+
return $.$('[style*="display"]').style.display
|
|
203
|
+
},
|
|
204
|
+
action:equal
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
title:'Change element\'s style property',
|
|
208
|
+
expected:'block',
|
|
209
|
+
result:function({$}){
|
|
210
|
+
let element = $.$('[style*="display"]')
|
|
211
|
+
element.style.display = 'block'
|
|
212
|
+
return element.style.display
|
|
213
|
+
},
|
|
214
|
+
action:equal
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
title:'Changins element\'s style, change attribs.style too',
|
|
218
|
+
expected:true,
|
|
219
|
+
result:function({$}){
|
|
220
|
+
let element = $.$('[style*="display"]')
|
|
221
|
+
element.style.display = 'flex'
|
|
222
|
+
return element.attribs.style.includes('flex')
|
|
223
|
+
},
|
|
224
|
+
action:equal
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
title:'Deleting element\'s style property',
|
|
228
|
+
expected:undefined,
|
|
229
|
+
result:function({$}){
|
|
230
|
+
let element = $.$('[style*="display"]')
|
|
231
|
+
delete element.style.display
|
|
232
|
+
return element.style.display
|
|
233
|
+
},
|
|
234
|
+
action:equal
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
title:'Deleting element\'s style, change attribs.style too',
|
|
238
|
+
expected:false,
|
|
239
|
+
result:function({$}){
|
|
240
|
+
let element = $.$('[style*="background-color"]')
|
|
241
|
+
delete element.style.backgroundColor
|
|
242
|
+
return element.attribs.style.includes('background-color')
|
|
243
|
+
},
|
|
244
|
+
action:equal
|
|
245
|
+
},
|
|
246
|
+
{title:'Classlist action tests'},
|
|
247
|
+
{
|
|
248
|
+
title:'add class',
|
|
249
|
+
expected:true,
|
|
250
|
+
result: function({$}){
|
|
251
|
+
let el = $.$('.tabs')
|
|
252
|
+
el.classList.add('super')
|
|
253
|
+
return el.classList.includes('super')
|
|
254
|
+
},
|
|
255
|
+
action:equal
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
title:'Adding class, changing attribs.class too',
|
|
259
|
+
expected:true,
|
|
260
|
+
result: function({$}){
|
|
261
|
+
let el = $.$('.tabs')
|
|
262
|
+
el.classList.add('puper')
|
|
263
|
+
return el.attribs.class.includes('puper')
|
|
264
|
+
},
|
|
265
|
+
action:equal
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
title:'remove class',
|
|
269
|
+
expected:function({$}) {
|
|
270
|
+
return $.$('.tabs').classList.includes('super')
|
|
271
|
+
},
|
|
272
|
+
result: function({$}){
|
|
273
|
+
let el = $.$('.tabs')
|
|
274
|
+
el.classList.remove('super')
|
|
275
|
+
return el.classList.includes('super')
|
|
276
|
+
},
|
|
277
|
+
action:notEqual
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
title:'Removing class, removing class in attribs.class too',
|
|
281
|
+
expected:function({$}) {
|
|
282
|
+
return $.$('.tabs').attribs.class.includes('puper')
|
|
283
|
+
},
|
|
284
|
+
result: function({$}){
|
|
285
|
+
let el = $.$('.tabs')
|
|
286
|
+
el.classList.remove('puper')
|
|
287
|
+
return el.attribs.class.includes('puper')
|
|
288
|
+
},
|
|
289
|
+
action:notEqual
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
title:'Test id getter',
|
|
293
|
+
expected:'test-id',
|
|
294
|
+
result:function({$}){
|
|
295
|
+
return $.$('[id]').id
|
|
296
|
+
},
|
|
297
|
+
action:equal
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
title:'Test id setter',
|
|
301
|
+
expected:'another-one',
|
|
302
|
+
result:function({$}){
|
|
303
|
+
$.$('[id]').id = 'another-one'
|
|
304
|
+
return $.$('[id]').id
|
|
305
|
+
},
|
|
306
|
+
action:equal
|
|
307
|
+
},
|
|
308
|
+
{title:'Test attributes'},
|
|
309
|
+
{
|
|
310
|
+
title:'Get attribute',
|
|
311
|
+
expected:function({$}) {
|
|
312
|
+
return $.$('input').attribs.type
|
|
313
|
+
},
|
|
314
|
+
result:function({$}){
|
|
315
|
+
return $.$('input').attr('type')
|
|
316
|
+
},
|
|
317
|
+
action:equal
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
title:'Set attribute',
|
|
321
|
+
expected:function({$}) {
|
|
322
|
+
return $.$('input').attribs.name
|
|
323
|
+
},
|
|
324
|
+
result:function({$}){
|
|
325
|
+
let input = $.$('input')
|
|
326
|
+
input.attr('name','name-changed')
|
|
327
|
+
return input.attr('name')
|
|
328
|
+
},
|
|
329
|
+
action:notEqual
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
title:'Remove attribute',
|
|
333
|
+
expected:function({$}) {
|
|
334
|
+
return Object.keys($.$('input').attribs).includes('checked')
|
|
335
|
+
},
|
|
336
|
+
result:function({$}){
|
|
337
|
+
let input = $.$('input')
|
|
338
|
+
input.attr('checked',null)
|
|
339
|
+
return Object.keys($.$('input').attribs).includes('checked')
|
|
340
|
+
},
|
|
341
|
+
action:notEqual
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
title:'Style not changable',
|
|
345
|
+
expected:function({$}) {
|
|
346
|
+
return $.$('[style]').attr('style')
|
|
347
|
+
},
|
|
348
|
+
result:function({$}){
|
|
349
|
+
$.$('[style]').attr('style','style has changed')
|
|
350
|
+
return $.$('[style]').attr('style')
|
|
351
|
+
},
|
|
352
|
+
action:equal
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
title:'Id not changable',
|
|
356
|
+
expected:function({$}) {
|
|
357
|
+
return $.$('[id]').attr('id')
|
|
358
|
+
},
|
|
359
|
+
result:function({$}){
|
|
360
|
+
$.$('[id]').attr('id','id has changed')
|
|
361
|
+
return $.$('[id]').attr('id')
|
|
362
|
+
},
|
|
363
|
+
action:equal
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
title:'Class not removable',
|
|
367
|
+
expected:function({$}) {
|
|
368
|
+
return $.$('[class]').attr('class')
|
|
369
|
+
},
|
|
370
|
+
result:function({$}){
|
|
371
|
+
$.$('[class]').attr('class',null)
|
|
372
|
+
return $.$('[class]').attr('class')
|
|
373
|
+
},
|
|
374
|
+
action:equal
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
title:'style not removable',
|
|
378
|
+
expected:function({$}) {
|
|
379
|
+
return $.$('[style]').attr('style')
|
|
380
|
+
},
|
|
381
|
+
result:function({$}){
|
|
382
|
+
$.$('[style]').attr('style',null)
|
|
383
|
+
return $.$('[style]').attr('style')
|
|
384
|
+
},
|
|
385
|
+
action:equal
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
title:'id not removable',
|
|
389
|
+
expected:function({$}) {
|
|
390
|
+
return $.$('[id]').attr('id')
|
|
391
|
+
},
|
|
392
|
+
result:function({$}){
|
|
393
|
+
$.$('[id]').attr('id',null)
|
|
394
|
+
return $.$('[id]').attr('id')
|
|
395
|
+
},
|
|
396
|
+
action:equal
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
title:'outerHTML changing then attribute changing',
|
|
400
|
+
expected:function({$}) {
|
|
401
|
+
return $.$('script').outerHTML.length
|
|
402
|
+
},
|
|
403
|
+
result:function({$}){
|
|
404
|
+
$.$('script').attr('src','some-test')
|
|
405
|
+
return $.$('script').outerHTML.length
|
|
406
|
+
},
|
|
407
|
+
action:notEqual
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
title:'remove element - children length',
|
|
411
|
+
expected:function({$}) {
|
|
412
|
+
return $.$('input').parent.children.length
|
|
413
|
+
},
|
|
414
|
+
result:function({$}) {
|
|
415
|
+
let el = $.$('input')
|
|
416
|
+
let parent = el.parent
|
|
417
|
+
el.remove()
|
|
418
|
+
return parent.children.length
|
|
419
|
+
},
|
|
420
|
+
action:greater
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
title:'remove element - parent elements change',
|
|
424
|
+
expected:function({$}) {
|
|
425
|
+
return $.$('input').parent.elements.length
|
|
426
|
+
},
|
|
427
|
+
result:function({$}) {
|
|
428
|
+
let el = $.$('input')
|
|
429
|
+
let count = el.elements.length
|
|
430
|
+
let parent = el.parent
|
|
431
|
+
el.remove()
|
|
432
|
+
return parent.elements.length+count
|
|
433
|
+
},
|
|
434
|
+
action:equal
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
title:'remove element - innerHTML changed',
|
|
438
|
+
expected:function({$}) {
|
|
439
|
+
return $.$('input').parent.innerHTML.length
|
|
440
|
+
},
|
|
441
|
+
result:function({$}) {
|
|
442
|
+
let el = $.$('input')
|
|
443
|
+
let parent = el.parent
|
|
444
|
+
el.remove()
|
|
445
|
+
return parent.innerHTML.length
|
|
446
|
+
},
|
|
447
|
+
action:greater
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
title:'Create $',
|
|
451
|
+
result: function({html2}){
|
|
452
|
+
this.vars.$ = new Document(html2)
|
|
453
|
+
return 'Done'
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
title:'Check selector',
|
|
458
|
+
expected:89,
|
|
459
|
+
result: function({$}){
|
|
460
|
+
return $.$('div').index
|
|
461
|
+
},
|
|
462
|
+
action:equal
|
|
463
|
+
},
|
|
464
|
+
{title:'Insert tests'},
|
|
465
|
+
{
|
|
466
|
+
title:'insert before',
|
|
467
|
+
expected:'test-id',
|
|
468
|
+
result: function({$,code1}){
|
|
469
|
+
let div = $.$('div')
|
|
470
|
+
div.insert(code1,0)
|
|
471
|
+
return $.$('div').id
|
|
472
|
+
},
|
|
473
|
+
action:equal
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
title:'Check if new element, includes it\'s children',
|
|
477
|
+
expected:'Hello world',
|
|
478
|
+
result: function({$}){
|
|
479
|
+
return $.$('div').children[1].text
|
|
480
|
+
},
|
|
481
|
+
action:equal
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
title:'Check if new element, includes it\'s children',
|
|
485
|
+
expected:'test',
|
|
486
|
+
result: function({$}){
|
|
487
|
+
return $.$('div').children[0].innerHTML
|
|
488
|
+
},
|
|
489
|
+
action:equal
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
title:'Move existing element',
|
|
493
|
+
expected:'test-id',
|
|
494
|
+
result: function({$}){
|
|
495
|
+
let div = $.$('div')
|
|
496
|
+
let script = $.$('script')
|
|
497
|
+
script.insert(div,0)
|
|
498
|
+
return script.prev.id
|
|
499
|
+
},
|
|
500
|
+
action:equal
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
title:'Insert after',
|
|
504
|
+
expected:'test-id',
|
|
505
|
+
result: function({$}){
|
|
506
|
+
let div = $.$('div')
|
|
507
|
+
let script = $.$('script')
|
|
508
|
+
script.insert(div,3)
|
|
509
|
+
return script.next.id
|
|
510
|
+
},
|
|
511
|
+
action:equal
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
title:'Insert as first child',
|
|
515
|
+
expected:'script',
|
|
516
|
+
result: function({$}){
|
|
517
|
+
let script = $.$('script')
|
|
518
|
+
let div = $.$('div')
|
|
519
|
+
div.insert(script,1)
|
|
520
|
+
return div.children[0].tag
|
|
521
|
+
},
|
|
522
|
+
action:equal
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
title:'Insert as last child',
|
|
526
|
+
expected:'script',
|
|
527
|
+
result: function({$}){
|
|
528
|
+
let span = $.$('span')
|
|
529
|
+
let script = $.$('script')
|
|
530
|
+
span.insert(script,2)
|
|
531
|
+
return span.children[1].tag
|
|
532
|
+
},
|
|
533
|
+
action:equal
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
title:'setter before - number of parent children',
|
|
537
|
+
expected:function({$}) {
|
|
538
|
+
return $.$('#container').children.length
|
|
539
|
+
},
|
|
540
|
+
result:function({$}) {
|
|
541
|
+
$.$('#container>#navbarDropMenu').before = '<div id="test1">Test</div>'
|
|
542
|
+
return $.$('#container').children.length
|
|
543
|
+
},
|
|
544
|
+
action:smaller
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
title:'setter before - index of element',
|
|
548
|
+
expected:function({$}) {
|
|
549
|
+
return $.$('#container').index
|
|
550
|
+
},
|
|
551
|
+
result:function({$}) {
|
|
552
|
+
let el = $.$('#container')
|
|
553
|
+
let next = el.next
|
|
554
|
+
el.before = next
|
|
555
|
+
return el.prev.index
|
|
556
|
+
},
|
|
557
|
+
action:equal
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
title:'setter after - number of parent children',
|
|
561
|
+
expected:function({$}) {
|
|
562
|
+
return $.$('#container').children.length
|
|
563
|
+
},
|
|
564
|
+
result:function({$}) {
|
|
565
|
+
$.$('#container>#navbarDropMenu').after = '<div id="test2">Test</div>'
|
|
566
|
+
return $.$('#container').children.length
|
|
567
|
+
},
|
|
568
|
+
action:smaller
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
title:'setter after - index of element',
|
|
572
|
+
expected:function({$}) {
|
|
573
|
+
return $.$('#container').endIndex+1
|
|
574
|
+
},
|
|
575
|
+
result:function({$}) {
|
|
576
|
+
let el = $.$('#container')
|
|
577
|
+
let el2 = el.prev
|
|
578
|
+
el.after = el2
|
|
579
|
+
return el2.index + el2.elements.length
|
|
580
|
+
},
|
|
581
|
+
action:equal
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
title:'first - childIndex',
|
|
585
|
+
expected:0,
|
|
586
|
+
result:function({$}) {
|
|
587
|
+
let tabs = $.$('#container')
|
|
588
|
+
let child = tabs.children[1]
|
|
589
|
+
tabs.first = child
|
|
590
|
+
return child.childIndex
|
|
591
|
+
},
|
|
592
|
+
action:equal
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
title:'first - index',
|
|
596
|
+
expected:function({$}) {
|
|
597
|
+
return $.$('#container').children[0].index
|
|
598
|
+
},
|
|
599
|
+
result:function({$}) {
|
|
600
|
+
let tabs = $.$('#container')
|
|
601
|
+
let child = tabs.children[2]
|
|
602
|
+
tabs.first = child
|
|
603
|
+
return child.index
|
|
604
|
+
},
|
|
605
|
+
action:equal
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
title:'last - childIndex',
|
|
609
|
+
expected:function({$}){
|
|
610
|
+
let tabs = $.$('#container')
|
|
611
|
+
let last = tabs.children.length-1
|
|
612
|
+
return tabs.children[last].childIndex
|
|
613
|
+
},
|
|
614
|
+
result:function({$}) {
|
|
615
|
+
let tabs = $.$('#container')
|
|
616
|
+
let child = tabs.children[0]
|
|
617
|
+
tabs.last = child
|
|
618
|
+
return child.childIndex
|
|
619
|
+
},
|
|
620
|
+
action:equal
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
title:'last - index',
|
|
624
|
+
expected:function({$}) {
|
|
625
|
+
let tabs = $.$('#container')
|
|
626
|
+
let last = tabs.children.length-1
|
|
627
|
+
return tabs.children[last].index
|
|
628
|
+
},
|
|
629
|
+
result:function({$}) {
|
|
630
|
+
let tabs = $.$('#container')
|
|
631
|
+
let last = tabs.children[tabs.children.length-1]
|
|
632
|
+
let child = tabs.children[0]
|
|
633
|
+
tabs.last = child
|
|
634
|
+
return child.index+child.elements.length-last.elements.length
|
|
635
|
+
},
|
|
636
|
+
action:equal
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
title:'remove element - children length',
|
|
640
|
+
expected:function({$}) {
|
|
641
|
+
return $.$('.w3-bar-item').parent.children.length
|
|
642
|
+
},
|
|
643
|
+
result:function({$}) {
|
|
644
|
+
let el = $.$('.w3-bar-item')
|
|
645
|
+
let parent = el.parent
|
|
646
|
+
el.remove()
|
|
647
|
+
return parent.children.length
|
|
648
|
+
},
|
|
649
|
+
action:greater
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
title:'remove element - parent elements change',
|
|
653
|
+
expected:function({$}) {
|
|
654
|
+
return $.$('.w3-bar-item').parent.elements.length
|
|
655
|
+
},
|
|
656
|
+
result:function({$}) {
|
|
657
|
+
let el = $.$('.w3-bar-item')
|
|
658
|
+
let count = el.elements.length
|
|
659
|
+
let parent = el.parent
|
|
660
|
+
el.remove()
|
|
661
|
+
return parent.elements.length+count
|
|
662
|
+
},
|
|
663
|
+
action:equal
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
title:'remove element - innerHTML changed',
|
|
667
|
+
expected:function({$}) {
|
|
668
|
+
return $.$('.w3-bar-item').parent.innerHTML.length
|
|
669
|
+
},
|
|
670
|
+
result:function({$}) {
|
|
671
|
+
let el = $.$('.w3-bar-item')
|
|
672
|
+
let parent = el.parent
|
|
673
|
+
el.remove()
|
|
674
|
+
return parent.innerHTML.length
|
|
675
|
+
},
|
|
676
|
+
action:greater
|
|
677
|
+
},
|
|
678
|
+
])
|