Skip to content

Commit

Permalink
fix: fix initial input data format
Browse files Browse the repository at this point in the history
  • Loading branch information
konclave committed Oct 26, 2018
1 parent fc01cf4 commit 79f2483
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions __tests__/ccs.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CreditCardSpace from '../src/index';

describe('CreditCardSpace', () => {
document.body.innerHTML = '<input type="text" value="4111111111111111" />';
const input = document.querySelector('input');
const cc = new CreditCardSpace(input);
it('should format input initial data', () => {
expect(input.value).toEqual('4111 1111 1111 1111');
expect(cc.value()).toEqual('4111111111111111');
});
});
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class CreditCardSpace {
}
this.element = element;
attachEvents(element);
if (element.value) {
utils.formatInputValue(element);
}
}

value() {
Expand Down

0 comments on commit 79f2483

Please sign in to comment.