|
1 |
| -casper.test.begin('Outputting Objects', 8, function (test) { |
| 1 | +casper.test.begin('Outputting Objects', 15, function (test) { |
2 | 2 |
|
3 | 3 | casper
|
4 | 4 | .start('./fixtures/output-object.html')
|
5 | 5 | .then(function () {
|
6 |
| - test.assertSelectorHasText('#data', '{"test":{"prop":1}}') |
| 6 | + test.assertSelectorHasText('#data', '{"test":{"prop":1},"arr":[{"a":1}]}') |
7 | 7 | test.assertSelectorHasText('#obj', '{"prop":1}')
|
| 8 | + test.assertSelectorHasText('#arr', '[{"a":1}]') |
8 | 9 | })
|
9 | 10 | // setting a nested property
|
10 | 11 | .thenEvaluate(function () {
|
11 | 12 | test.test.prop = 2
|
12 | 13 | })
|
13 | 14 | .then(function () {
|
14 |
| - test.assertSelectorHasText('#data', '{"test":{"prop":2}}') |
| 15 | + test.assertSelectorHasText('#data', '{"test":{"prop":2},"arr":[{"a":1}]}') |
15 | 16 | test.assertSelectorHasText('#obj', '{"prop":2}')
|
16 | 17 | })
|
17 | 18 | // setting a nested object
|
18 | 19 | .thenEvaluate(function () {
|
19 | 20 | test.test = { hi:3 }
|
20 | 21 | })
|
21 | 22 | .then(function () {
|
22 |
| - test.assertSelectorHasText('#data', '{"test":{"hi":3}}') |
| 23 | + test.assertSelectorHasText('#data', '{"test":{"hi":3},"arr":[{"a":1}]}') |
23 | 24 | test.assertSelectorHasText('#obj', '{"hi":3}')
|
24 | 25 | })
|
| 26 | + // mutating an array |
| 27 | + .thenEvaluate(function () { |
| 28 | + test.arr.push({a:2}) |
| 29 | + }) |
| 30 | + .then(function () { |
| 31 | + test.assertSelectorHasText('#data', '{"test":{"hi":3},"arr":[{"a":1},{"a":2}]}') |
| 32 | + test.assertSelectorHasText('#arr', '[{"a":1},{"a":2}]') |
| 33 | + }) |
| 34 | + // no length change mutate an array |
| 35 | + .thenEvaluate(function () { |
| 36 | + test.arr.reverse() |
| 37 | + }) |
| 38 | + .then(function () { |
| 39 | + test.assertSelectorHasText('#data', '{"test":{"hi":3},"arr":[{"a":2},{"a":1}]}') |
| 40 | + test.assertSelectorHasText('#arr', '[{"a":2},{"a":1}]') |
| 41 | + }) |
| 42 | + // swap the array |
| 43 | + .thenEvaluate(function () { |
| 44 | + test.arr = [1,2,3] |
| 45 | + }) |
| 46 | + .then(function () { |
| 47 | + test.assertSelectorHasText('#data', '{"test":{"hi":3},"arr":[1,2,3]}') |
| 48 | + test.assertSelectorHasText('#arr', '[1,2,3]') |
| 49 | + }) |
25 | 50 | // setting $data
|
26 | 51 | .thenEvaluate(function () {
|
27 |
| - test.$data = { test: { swapped: true } } |
| 52 | + test.$data = { test: { swapped: true }, arr:[3,2,1] } |
28 | 53 | })
|
29 | 54 | .then(function () {
|
30 |
| - test.assertSelectorHasText('#data', '{"test":{"swapped":true}}') |
| 55 | + test.assertSelectorHasText('#data', '{"test":{"swapped":true},"arr":[3,2,1]}') |
31 | 56 | test.assertSelectorHasText('#obj', '{"swapped":true}')
|
32 | 57 | })
|
33 | 58 | .run(function () {
|
|
0 commit comments