github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/libs/vue-1.0.24/test/e2e/tree.js (about) 1 casper.test.begin('tree', 22, function (test) { 2 casper 3 .start('examples/tree/index.html') 4 .then(function () { 5 test.assertElementCount('.item', 12) 6 test.assertElementCount('.item > ul', 4) 7 test.assertNotVisible('#demo li ul') 8 test.assertSelectorHasText('#demo li div span', '[+]') 9 }) 10 .thenClick('.bold', function () { 11 test.assertVisible('#demo ul') 12 test.assertSelectorHasText('#demo li div span', '[-]') 13 test.assertSelectorHasText('#demo ul > .item:nth-child(1)', 'hello') 14 test.assertSelectorHasText('#demo ul > .item:nth-child(2)', 'wat') 15 test.assertSelectorHasText('#demo ul > .item:nth-child(3)', 'child folder') 16 test.assertSelectorHasText('#demo ul > .item:nth-child(3)', '[+]') 17 test.assertEval(function () { 18 return document.querySelector('#demo li ul').children.length === 4 19 }) 20 }) 21 .thenClick('#demo ul .bold', function () { 22 test.assertVisible('#demo ul ul') 23 test.assertSelectorHasText('#demo ul > .item:nth-child(3)', '[-]') 24 test.assertEval(function () { 25 return document.querySelector('#demo ul ul').children.length === 5 26 }) 27 }) 28 .thenClick('.bold', function () { 29 test.assertNotVisible('#demo ul') 30 test.assertSelectorHasText('#demo li div span', '[+]') 31 }) 32 .thenClick('.bold', function () { 33 test.assertVisible('#demo ul') 34 test.assertSelectorHasText('#demo li div span', '[-]') 35 }) 36 .then(function () { 37 casper.mouseEvent('dblclick', '#demo ul > .item div') 38 }) 39 .then(function () { 40 test.assertElementCount('.item', 13) 41 test.assertElementCount('.item > ul', 5) 42 test.assertSelectorHasText('#demo ul > .item:nth-child(1)', '[-]') 43 test.assertEval(function () { 44 var firstItem = document.querySelector('#demo ul > .item:nth-child(1)') 45 var ul = firstItem.querySelector('ul') 46 return ul.children.length === 2 47 }) 48 }) 49 // run 50 .run(function () { 51 test.done() 52 }) 53 })