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 to verify character counter is sert if…
Browse files Browse the repository at this point in the history
… setValue is called
  • Loading branch information
williamernest committed May 2, 2019
1 parent 837870f commit c4d4ad1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 39 deletions.
41 changes: 11 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions packages/mdc-animation/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions packages/mdc-dialog/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions packages/mdc-drawer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 c4d4ad1

Please sign in to comment.