@lion/validate
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.5.3](https://github.com/ing-bank/lion/compare/@lion/validate@0.5.2...@lion/validate@0.5.3) (2019-12-13) | ||
### Bug Fixes | ||
* **validate:** allow getMessage to return message based on config ([c21eabb](https://github.com/ing-bank/lion/commit/c21eabbacddf6c3afb007e21dc69a46be5169d7b)) | ||
## [0.5.2](https://github.com/ing-bank/lion/compare/@lion/validate@0.5.1...@lion/validate@0.5.2) (2019-12-03) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@lion/validate", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Validate your form elements", | ||
@@ -45,3 +45,3 @@ "author": "ing-bank", | ||
}, | ||
"gitHead": "37fd54a4218e59ce3a19cb5b07ff37279c3e6921" | ||
"gitHead": "e51bf720e5eef3575d07083a7fead0d10cf056e6" | ||
} |
@@ -58,2 +58,3 @@ import { fakeExtendsEventTarget } from './utils/fake-extends-event-target.js'; | ||
params: this.param, | ||
config: this.config, | ||
...data, | ||
@@ -60,0 +61,0 @@ }; |
@@ -405,2 +405,3 @@ import { expect, fixture, html, unsafeStatic, defineCE } from '@open-wc/testing'; | ||
expect(constructorMessageSpy.args[0][0]).to.eql({ | ||
config: { type: 'x' }, | ||
params: 4, | ||
@@ -427,2 +428,5 @@ modelValue: 'cat', | ||
expect(instanceMessageSpy.args[0][0]).to.eql({ | ||
config: { | ||
getMessage: instanceMessageSpy, | ||
}, | ||
params: 4, | ||
@@ -452,2 +456,3 @@ modelValue: 'cat', | ||
expect(spy.args[0][0]).to.eql({ | ||
config: {}, | ||
params: 4, | ||
@@ -479,3 +484,8 @@ modelValue: 'cat', | ||
await el.feedbackComplete; | ||
expect(spy.args[0][0]).to.eql({ | ||
// ignore fieldName Promise as it will always be unique | ||
const compare = spy.args[0][0]; | ||
delete compare.config.fieldName; | ||
expect(compare).to.eql({ | ||
config: {}, | ||
params: 4, | ||
@@ -482,0 +492,0 @@ modelValue: 'cat', |
@@ -35,2 +35,44 @@ import { expect, fixture, html, unsafeStatic, defineCE } from '@open-wc/testing'; | ||
it('has access to name, type, params, config in getMessage provided by config', () => { | ||
const configSpy = sinon.spy(); | ||
class MyValidator extends Validator { | ||
constructor(...args) { | ||
super(...args); | ||
this.name = 'MyValidator'; | ||
} | ||
} | ||
const vali = new MyValidator('myParam', { my: 'config', getMessage: configSpy }); | ||
vali._getMessage(); | ||
expect(configSpy.args[0][0]).to.deep.equal({ | ||
name: 'MyValidator', | ||
type: 'error', | ||
params: 'myParam', | ||
config: { my: 'config', getMessage: configSpy }, | ||
}); | ||
}); | ||
it('has access to name, type, params, config in static get getMessage', () => { | ||
let staticArgs; | ||
class MyValidator extends Validator { | ||
constructor(...args) { | ||
super(...args); | ||
this.name = 'MyValidator'; | ||
} | ||
static getMessage(...args) { | ||
staticArgs = args; | ||
} | ||
} | ||
const vali = new MyValidator('myParam', { my: 'config' }); | ||
vali._getMessage(); | ||
expect(staticArgs[0]).to.deep.equal({ | ||
name: 'MyValidator', | ||
type: 'error', | ||
params: 'myParam', | ||
config: { my: 'config' }, | ||
}); | ||
}); | ||
it('fires "param-changed" event on param change', async () => { | ||
@@ -37,0 +79,0 @@ const vali = new Validator('foo'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
214280
4682