From 8a8f82b8727c3f1165a21c0e1884937faaa122ef Mon Sep 17 00:00:00 2001 From: Brian Suh Date: Tue, 30 Sep 2014 10:41:53 -0700 Subject: [PATCH] added regression test for #288 --- tests/e2e/tests.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/e2e/tests.js b/tests/e2e/tests.js index 6d3cae96..33d4ef71 100644 --- a/tests/e2e/tests.js +++ b/tests/e2e/tests.js @@ -262,3 +262,39 @@ asyncTest('issue214 regression', function() { 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() + }) +})