Merge pull request #293 from bsuh/regression-tests

Regression tests #214 and #288
This commit is contained in:
Leo Horie 2014-10-02 17:52:53 -04:00
commit 35d328f416
3 changed files with 2922 additions and 0 deletions

2858
tests/e2e/libs/syn.js Normal file

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,7 @@
<link rel="stylesheet" href="libs/qunit.css" media="screen">
<script src="libs/qunit.js"></script>
<!-- Load local lib and tests. -->
<script src="libs/syn.js"></script>
<script src="../../mithril.js"></script>
</head>
<body>

View file

@ -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.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()
})
})