Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
fix(text-field): Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
williamernest committed May 3, 2019
1 parent ec25176 commit 2d12096
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/unit/mdc-textfield/foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,22 @@ test('#setValue updates character counter when present', () => {
td.verify(characterCounter.setCounterValue(2, 4), {times: 1});
});

test('#setValue forces the character counter to update if value was updated independently', () => {
const {foundation, mockAdapter, characterCounter} = setupTest({useCharacterCounter: true});
const nativeInput = {
type: 'text',
value: '',
maxLength: 4,
validity: {
valid: true,
},
};
td.when(mockAdapter.getNativeInput()).thenReturn(nativeInput);
nativeInput.value = 'ok';
foundation.setValue('ok');
td.verify(characterCounter.setCounterValue(2, 4), {times: 1});
});

test('#isValid for native validation', () => {
const {foundation, nativeInput} = setupValueTest({value: '', optIsValid: true});
assert.isOk(foundation.isValid());
Expand Down

0 comments on commit 2d12096

Please sign in to comment.