Merge pull request #293 from bsuh/regression-tests
Regression tests #214 and #288
This commit is contained in:
commit
35d328f416
3 changed files with 2922 additions and 0 deletions
2858
tests/e2e/libs/syn.js
Normal file
2858
tests/e2e/libs/syn.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -7,6 +7,7 @@
|
||||||
<link rel="stylesheet" href="libs/qunit.css" media="screen">
|
<link rel="stylesheet" href="libs/qunit.css" media="screen">
|
||||||
<script src="libs/qunit.js"></script>
|
<script src="libs/qunit.js"></script>
|
||||||
<!-- Load local lib and tests. -->
|
<!-- Load local lib and tests. -->
|
||||||
|
<script src="libs/syn.js"></script>
|
||||||
<script src="../../mithril.js"></script>
|
<script src="../../mithril.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -235,3 +235,66 @@ test('node identity shuffle and remove', function() {
|
||||||
equal(dummyEl.firstChild.firstChild.nextSibling.nextSibling, e1, 'e1 is third element')
|
equal(dummyEl.firstChild.firstChild.nextSibling.nextSibling, e1, 'e1 is third element')
|
||||||
equal(dummyEl.firstChild.firstChild.nextSibling.nextSibling.nextSibling, e2, 'e2 is fourth element')
|
equal(dummyEl.firstChild.firstChild.nextSibling.nextSibling.nextSibling, e2, 'e2 is fourth element')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
asyncTest('issue214 regression', function() {
|
||||||
|
// see https://github.com/lhorie/mithril.js/issues/214
|
||||||
|
// this test will pass using phantomjs, because phantomjs
|
||||||
|
// doesn't provide window.requestAnimationFrame
|
||||||
|
expect(2)
|
||||||
|
|
||||||
|
function controller() {
|
||||||
|
this.inputValue = m.prop('')
|
||||||
|
}
|
||||||
|
|
||||||
|
function view(ctrl) {
|
||||||
|
return m('input#testinput', {
|
||||||
|
value: ctrl.inputValue(),
|
||||||
|
onkeyup: m.withAttr('value', ctrl.inputValue)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var ctrl = m.module(dummyEl, { controller: controller, view: view })
|
||||||
|
|
||||||
|
Syn.click({}, 'testinput')
|
||||||
|
.type('eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', function() {
|
||||||
|
equal(ctrl.inputValue(), 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee')
|
||||||
|
equal(document.getElementById('testinput').value, 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee')
|
||||||
|
start()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
asyncTest('issue288 regression', function() {
|
||||||
|
// see https://github.com/lhorie/mithril.js/issues/288
|
||||||
|
// this test will pass using phantomjs, because phantomjs
|
||||||
|
// doesn't provide window.requestAnimationFrame
|
||||||
|
expect(2)
|
||||||
|
|
||||||
|
function controller() {
|
||||||
|
this.inputValue = m.prop('')
|
||||||
|
|
||||||
|
this.submit = function() {
|
||||||
|
if (this.inputValue()) {
|
||||||
|
this.inputValue('')
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
function view(ctrl) {
|
||||||
|
return m('form', { onsubmit: ctrl.submit }, [
|
||||||
|
m('input#testinput', {
|
||||||
|
onkeyup: m.withAttr('value', ctrl.inputValue),
|
||||||
|
value: ctrl.inputValue()
|
||||||
|
}),
|
||||||
|
m('button[type=submit]')
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
var ctrl = m.module(dummyEl, { controller: controller, view: view })
|
||||||
|
|
||||||
|
Syn.click({}, 'testinput')
|
||||||
|
.type('abcd[enter]', function() {
|
||||||
|
equal(ctrl.inputValue(), '')
|
||||||
|
equal(document.getElementById('testinput').value, '')
|
||||||
|
start()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue