Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Jun 27, 2022
1 parent b087222 commit 7a71d4c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/field-base/test/validate-mixin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,34 @@ const runTests = (baseClass) => {
expect(event.detail.valid).to.be.false;
});
});

describe('only validation failure is committed', () => {
const tagWithOnlyFailureCommitted = define[baseClass](
'validate-mixin-with-only-failure-committed',
'<input>',
(Base) =>
class extends ValidateMixin(Base) {
_shouldCommitValidationResult(isValid) {
return !isValid;
}
},
);

beforeEach(async () => {
element = fixtureSync(`<${tagWithOnlyFailureCommitted}></${tagWithOnlyFailureCommitted}>`);
await nextRender();
});

it('should not commit validation success', () => {
element.required = true;
element.validate();
expect(element.invalid).to.be.true;

element.value = 'value';
element.validate();
expect(element.invalid).to.be.true;
});
});
};

describe('ValidateMixin + Polymer', () => {
Expand Down

0 comments on commit 7a71d4c

Please sign in to comment.