Co-authored-by: Alex Ghiu <alex.ghiu@ing.com> Co-authored-by: Gerjan van Geest <Gerjan.van.Geest@ing.com> Co-authored-by: Thijs Louisse <Thijs.Louisse@ing.com> Co-authored-by: Joren Broekema <joren.broekema@ing.com> Co-authored-by: Erik Kroes <erik.kroes@ing.com>
22 lines
881 B
JavaScript
22 lines
881 B
JavaScript
import { expect } from '@open-wc/testing';
|
|
import { ResultValidator } from '../src/ResultValidator.js';
|
|
import { Required } from '../src/validators/Required.js';
|
|
import { MinLength } from '../src/validators/StringValidators.js';
|
|
|
|
describe('ResultValidator', () => {
|
|
it('has an "executeOnResults" function returning active state', async () => {
|
|
// This test shows the best practice of creating executeOnResults method
|
|
class MyResultValidator extends ResultValidator {
|
|
executeOnResults({ regularValidateResult, prevValidationResult }) {
|
|
const hasSuccess = regularValidateResult.length && !prevValidationResult.length;
|
|
return hasSuccess;
|
|
}
|
|
}
|
|
expect(
|
|
new MyResultValidator().executeOnResults({
|
|
regularValidateResult: [new Required(), new MinLength(3)],
|
|
prevValidationResult: [],
|
|
}),
|
|
).to.be.true;
|
|
});
|
|
});
|