fix(validate): add attributes for validation states
This commit is contained in:
parent
b9012fe2ba
commit
f4fb438363
2 changed files with 59 additions and 0 deletions
|
|
@ -119,9 +119,13 @@ export const ValidateMixin = dedupeMixin(
|
||||||
},
|
},
|
||||||
errorState: {
|
errorState: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'error-state',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
errorShow: {
|
errorShow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'error-show',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
warningValidators: {
|
warningValidators: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
@ -131,9 +135,13 @@ export const ValidateMixin = dedupeMixin(
|
||||||
},
|
},
|
||||||
warningState: {
|
warningState: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'warning-state',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
warningShow: {
|
warningShow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'warning-show',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
infoValidators: {
|
infoValidators: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
@ -143,9 +151,13 @@ export const ValidateMixin = dedupeMixin(
|
||||||
},
|
},
|
||||||
infoState: {
|
infoState: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'info-state',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
infoShow: {
|
infoShow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'info-show',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
successValidators: {
|
successValidators: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
@ -155,12 +167,17 @@ export const ValidateMixin = dedupeMixin(
|
||||||
},
|
},
|
||||||
successState: {
|
successState: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'success-state',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
successShow: {
|
successShow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
attribute: 'success-show',
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
invalid: {
|
invalid: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
reflect: true,
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,48 @@ describe('ValidateMixin', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('sets attribute "(error|warning|info|success|invalid)-state"', async () => {
|
||||||
|
const el = await fixture(html`<${tag}></${tag}>`);
|
||||||
|
el.errorState = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('error-state'), 'has error-state attribute').to.be.true;
|
||||||
|
|
||||||
|
el.warningState = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('warning-state'), 'has warning-state attribute').to.be.true;
|
||||||
|
|
||||||
|
el.infoState = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('info-state'), 'has info-state attribute').to.be.true;
|
||||||
|
|
||||||
|
el.successState = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('success-state'), 'has error-state attribute').to.be.true;
|
||||||
|
|
||||||
|
el.invalid = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('invalid'), 'has invalid attribute').to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets attribute "(error|warning|info|success)-show"', async () => {
|
||||||
|
const el = await fixture(html`<${tag}></${tag}>`);
|
||||||
|
el.errorShow = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('error-show'), 'has error-show attribute').to.be.true;
|
||||||
|
|
||||||
|
el.warningShow = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('warning-show'), 'has warning-show attribute').to.be.true;
|
||||||
|
|
||||||
|
el.infoShow = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('info-show'), 'has info-show attribute').to.be.true;
|
||||||
|
|
||||||
|
el.successShow = true;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.hasAttribute('success-show'), 'has success-show attribute').to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
describe(`Validators ${suffixName}`, () => {
|
describe(`Validators ${suffixName}`, () => {
|
||||||
function isCat(modelValue, opts) {
|
function isCat(modelValue, opts) {
|
||||||
const validateString = opts && opts.number ? `cat${opts.number}` : 'cat';
|
const validateString = opts && opts.number ? `cat${opts.number}` : 'cat';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue