diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-09 14:33:05 +0000 |
|---|---|---|
| committer | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-09 14:33:05 +0000 |
| commit | 2e4756eaf97fd70c4917d01a1284887bdec28956 (patch) | |
| tree | 035c41b684ea54d0901a2d04b3d06833d39a10b6 /test/components | |
| parent | 4005868e4c28e526f26858f5721da7d50809d05e (diff) | |
| download | mullvadvpn-2e4756eaf97fd70c4917d01a1284887bdec28956.tar.xz mullvadvpn-2e4756eaf97fd70c4917d01a1284887bdec28956.zip | |
- Add basic tests for AccountInput
- Add JSDOM
Diffstat (limited to 'test/components')
| -rw-r--r-- | test/components/AccountInput.spec.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/components/AccountInput.spec.js b/test/components/AccountInput.spec.js new file mode 100644 index 0000000000..ba2522c224 --- /dev/null +++ b/test/components/AccountInput.spec.js @@ -0,0 +1,48 @@ +import { expect } from 'chai'; +import { KeyType, createKeyEvent } from '../mocks/dom'; + +import React from 'react'; +import ReactTestUtils from 'react-addons-test-utils'; +import AccountInput from '../../app/components/AccountInput'; + +describe('components: AccountInput', () => { + + it('should call onEnter', (done) => { + const onEnter = () => { + done(); + }; + + const component = ReactTestUtils.renderIntoDocument( + <AccountInput onEnter={ onEnter } /> + ); + + ReactTestUtils.Simulate.keyUp(component._ref, createKeyEvent(KeyType.Enter)); + }); + + it('should call onChange', (done) => { + const onChange = (val) => { + expect(val).equal('1'); + done(); + }; + + const component = ReactTestUtils.renderIntoDocument( + <AccountInput onChange={ onChange } /> + ); + + ReactTestUtils.Simulate.keyDown(component._ref, createKeyEvent(KeyType._1)); + }); + + it('should remove last character', (done) => { + const onChange = (val) => { + expect(val).equal('123'); + done(); + }; + + const component = ReactTestUtils.renderIntoDocument( + <AccountInput value="1234" onChange={ onChange } /> + ); + + ReactTestUtils.Simulate.keyDown(component._ref, createKeyEvent(KeyType.Backspace)); + }); + +});
\ No newline at end of file |
