Skip to content

Commit

Permalink
Add failing test case to reproduce behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali committed Feb 13, 2021
1 parent 0c47545 commit a25551c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/integration/components/one-way-input-mask-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,36 @@ module('Integration | Component | one-way-input-mask', function(hooks) {

await fillIn('input', '155');
assert.dom('input').hasValue('15');
});

test('Inputs value correcly even when input have multiple masks', async function(assert) {
this.set('masks', ['9.9.9', '99.9-9']);
this.set('data', null);
this.set('update', (unmasked) => {
this.set('data', unmasked)
})

await render(hbs`<OneWayInputMask @value={{data}} @mask={{this.masks}} @update={{update}} />`);

await focus('input');
await triggerKeyEvent('input', 'keypress', '1');
await triggerKeyEvent('input', 'keydown', '1');
await triggerKeyEvent('input', 'keyup', '1');

await triggerKeyEvent('input', 'keypress', '3');
await triggerKeyEvent('input', 'keydown', '3');
await triggerKeyEvent('input', 'keyup', '3');

await triggerKeyEvent('input', 'keypress', '4');
await triggerKeyEvent('input', 'keydown', '4');
await triggerKeyEvent('input', 'keyup', '4');

assert.dom('input').hasValue("1.3.4");

await triggerKeyEvent('input', 'keypress', '5');
await triggerKeyEvent('input', 'keydown', '5');
await triggerKeyEvent('input', 'keyup', '5');

assert.dom('input').hasValue("13.4-5");
});
});

0 comments on commit a25551c

Please sign in to comment.