Skip to content

Commit 519a5ca

Browse files
committed
add more tests
1 parent d4e44dd commit 519a5ca

File tree

7 files changed

+185
-12112
lines changed

7 files changed

+185
-12112
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import get from 'lodash/get';
12
import { expect } from 'chai';
2-
import { interpolateErrors, validateProcess } from '../index';
3+
import { validateProcess } from '../index';
34
import { rules } from "../rules";
45
import { simpleForm } from './fixtures/forms';
56
import { ProcessorType, ValidationScope } from 'types';
6-
import { FieldError, InterpolateErrorFn } from 'error';
7-
import get from 'lodash/get';
87

98
it('Validator will throw the correct errors given a flat components array', async () => {
109
let errors: string[] = [];
@@ -37,43 +36,3 @@ it('Validator will throw the correct errors given a flat components array', asyn
3736
}
3837
expect(errors).to.have.length(6);
3938
});
40-
41-
it('Validation errors (FieldErrors) should include the rule name mapping in the "validator" param', async () => {
42-
const data = {
43-
requiredField: '',
44-
maximumWords: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
45-
minimumWords: 'Hello',
46-
email: 'brendanb',
47-
url: 'htpigoogle',
48-
inputMask: 'hello, world',
49-
submit: false,
50-
};
51-
const result: Map<string, ReturnType<typeof interpolateErrors>> = new Map();
52-
for (let component of simpleForm.components) {
53-
const path = component.key;
54-
const scope: ValidationScope = { errors: [] };
55-
await validateProcess({
56-
component,
57-
scope,
58-
data,
59-
row: data,
60-
path,
61-
value: get(data, component.key),
62-
processor: ProcessorType.Validate,
63-
rules
64-
});
65-
result.set(path, interpolateErrors(scope.errors));
66-
}
67-
expect(result.get('requiredField')).to.have.length(1);
68-
expect(result.get('requiredField')![0].context.validator).to.equal('required');
69-
expect(result.get('maximumWords')).to.have.length(1);
70-
expect(result.get('maximumWords')![0].context.validator).to.equal('maxWords');
71-
expect(result.get('minimumWords')).to.have.length(1);
72-
expect(result.get('minimumWords')![0].context.validator).to.equal('minWords');
73-
expect(result.get('email')).to.have.length(1);
74-
expect(result.get('email')![0].context.validator).to.equal('email');
75-
expect(result.get('url')).to.have.length(1);
76-
expect(result.get('url')![0].context.validator).to.equal('url');
77-
expect(result.get('inputMask')).to.have.length(1);
78-
expect(result.get('inputMask')![0].context.validator).to.equal('inputMask');
79-
});

src/process/validation/__tests__/fixtures/components.d.ts

-31
This file was deleted.

src/process/validation/__tests__/fixtures/components.js

-196
This file was deleted.

0 commit comments

Comments
 (0)