summaryrefslogtreecommitdiffhomepage
path: root/test/components/AccountInput.spec.js
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-06-01 16:13:10 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-06-05 12:11:55 +0200
commitca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087 (patch)
treeb1f7754eb50896ab3681e35fa4e08be642b940c9 /test/components/AccountInput.spec.js
parent5852c980980de53e00d76a0bdb4b41bf5c0f5b39 (diff)
downloadmullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.tar.xz
mullvadvpn-ca2f6fbfcad7b73d4ea63ef46cb1cab943ec9087.zip
Add formatted source code
Diffstat (limited to 'test/components/AccountInput.spec.js')
-rw-r--r--test/components/AccountInput.spec.js37
1 files changed, 17 insertions, 20 deletions
diff --git a/test/components/AccountInput.spec.js b/test/components/AccountInput.spec.js
index a10326bc17..25f2e366b7 100644
--- a/test/components/AccountInput.spec.js
+++ b/test/components/AccountInput.spec.js
@@ -18,17 +18,15 @@ describe('components/AccountInput', () => {
const defaultProps: AccountInputProps = {
value: '',
onEnter: null,
- onChange: null
+ onChange: null,
};
const props = Object.assign({}, defaultProps, mergeProps);
- return shallow(
- <AccountInput {...props} />
- );
+ return shallow(<AccountInput {...props} />);
};
it('should call onEnter', (done) => {
const component = render({
- onEnter: () => done()
+ onEnter: () => done(),
});
keyPress(getInputRef(component), createKeyEvent('Enter'));
});
@@ -38,7 +36,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('1');
done();
- }
+ },
});
keyPress(getInputRef(component), createKeyEvent('1'));
});
@@ -58,10 +56,10 @@ describe('components/AccountInput', () => {
'111',
'11',
'1',
- ''
+ '',
];
- for(const value of cases) {
+ for (const value of cases) {
const component = render({ value });
expect(getInputRef(component).prop('value')).to.be.equal(value);
}
@@ -73,7 +71,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('123');
done();
- }
+ },
});
keyPress(getInputRef(component), createKeyEvent('Backspace'));
});
@@ -84,7 +82,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('234');
done();
- }
+ },
});
component.setState({ selectionRange: [1, 1] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -97,7 +95,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.empty;
done();
- }
+ },
});
component.setState({ selectionRange: [0, 8] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -110,7 +108,7 @@ describe('components/AccountInput', () => {
onChange: (val) => {
expect(val).to.be.equal('12349999');
done();
- }
+ },
});
component.setState({ selectionRange: [4, 8] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -119,7 +117,7 @@ describe('components/AccountInput', () => {
it('should replace selection', (done) => {
const component = render({
- value: '0000'
+ value: '0000',
});
component.setState({ selectionRange: [1, 3] }, () => {
@@ -136,7 +134,7 @@ describe('components/AccountInput', () => {
it('should keep selection in the back', (done) => {
const component = render({ value: '' });
- for(let i = 0; i < 12; i++) {
+ for (let i = 0; i < 12; i++) {
keyPress(getInputRef(component), createKeyEvent('1'));
}
@@ -149,9 +147,9 @@ describe('components/AccountInput', () => {
it('should advance selection on insertion', (done) => {
const component = render({
- value: '0000'
+ value: '0000',
});
- component.setState({ selectionRange: [1, 1]}, () => {
+ component.setState({ selectionRange: [1, 1] }, () => {
keyPress(getInputRef(component), createKeyEvent('1'));
component.setState({}, () => {
@@ -164,7 +162,7 @@ describe('components/AccountInput', () => {
it('should not do anything when nothing to remove', (done) => {
const component = render({
- value: '0000'
+ value: '0000',
});
component.setState({ selectionRange: [0, 0] }, () => {
keyPress(getInputRef(component), createKeyEvent('Backspace'));
@@ -176,13 +174,12 @@ describe('components/AccountInput', () => {
});
});
});
-
});
function getComponent(container, testName) {
- return container.findWhere( n => n.prop('testName') === testName);
+ return container.findWhere((n) => n.prop('testName') === testName);
}
function keyPress(component, key) {
component.prop('onKeyPress')(key);
-} \ No newline at end of file
+}