|
1 | 1 | /* @flow */
|
2 | 2 |
|
3 |
| -import { ValidationError } from '../src/ValidationError' |
| 3 | +import { ValidationError } from '../src/ValidationError'; |
4 | 4 |
|
5 | 5 | describe('ValidationError', () => {
|
6 | 6 | it('Have name, valueName, value, expectedTypes and message properties', () => {
|
7 |
| - const error = new ValidationError('valueName', 'value', 'type') |
| 7 | + const error = new ValidationError('valueName', 'value', 'type'); |
8 | 8 |
|
9 |
| - expect(error.name).toBe('ValidationError') |
10 |
| - expect(error.valueName).toBe('valueName') |
11 |
| - expect(error.value).toBe('value') |
12 |
| - expect(error.expectedTypes).toEqual(['type']) |
13 |
| - expect(error.message).toBe('valueName must be type, but "value" (string) given') |
14 |
| - }) |
| 9 | + expect(error.name).toBe('ValidationError'); |
| 10 | + expect(error.valueName).toBe('valueName'); |
| 11 | + expect(error.value).toBe('value'); |
| 12 | + expect(error.expectedTypes).toEqual(['type']); |
| 13 | + expect(error.message).toBe( |
| 14 | + 'valueName must be type, but "value" (string) given', |
| 15 | + ); |
| 16 | + }); |
15 | 17 |
|
16 | 18 | it('Have factory of()', () => {
|
17 |
| - const error = ValidationError.of('valueName', 'value', 'type') |
| 19 | + const error = ValidationError.of('valueName', 'value', 'type'); |
18 | 20 |
|
19 |
| - expect(error.name).toBe('ValidationError') |
20 |
| - expect(error.valueName).toBe('valueName') |
21 |
| - expect(error.value).toBe('value') |
22 |
| - expect(error.expectedTypes).toEqual(['type']) |
23 |
| - expect(error.message).toBe('valueName must be type, but "value" (string) given') |
24 |
| - }) |
| 21 | + expect(error.name).toBe('ValidationError'); |
| 22 | + expect(error.valueName).toBe('valueName'); |
| 23 | + expect(error.value).toBe('value'); |
| 24 | + expect(error.expectedTypes).toEqual(['type']); |
| 25 | + expect(error.message).toBe( |
| 26 | + 'valueName must be type, but "value" (string) given', |
| 27 | + ); |
| 28 | + }); |
25 | 29 |
|
26 | 30 | it('Have name, valueName, value, expectedTypes and message properties', () => {
|
27 |
| - const error = new ValidationError('valueName', 'value', 'type') |
| 31 | + const error = new ValidationError('valueName', 'value', 'type'); |
28 | 32 |
|
29 |
| - expect(error.name).toBe('ValidationError') |
30 |
| - expect(error.valueName).toBe('valueName') |
31 |
| - expect(error.value).toBe('value') |
32 |
| - expect(error.expectedTypes).toEqual(['type']) |
33 |
| - expect(error.message).toBe('valueName must be type, but "value" (string) given') |
34 |
| - }) |
| 33 | + expect(error.name).toBe('ValidationError'); |
| 34 | + expect(error.valueName).toBe('valueName'); |
| 35 | + expect(error.value).toBe('value'); |
| 36 | + expect(error.expectedTypes).toEqual(['type']); |
| 37 | + expect(error.message).toBe( |
| 38 | + 'valueName must be type, but "value" (string) given', |
| 39 | + ); |
| 40 | + }); |
35 | 41 |
|
36 | 42 | it('Can receive 1 and more types', () => {
|
37 |
| - const error1 = new ValidationError('valueName', 'value', 'type1') |
38 |
| - const error2 = new ValidationError('valueName', 'value', 'type1', 'type2') |
39 |
| - const error3 = new ValidationError('valueName', 'value', 'type1', 'type2', 'type3') |
40 |
| - |
41 |
| - expect(error1.message).toBe('valueName must be type1, but "value" (string) given') |
42 |
| - expect(error2.message).toBe('valueName must be type1 or type2, but "value" (string) given') |
43 |
| - expect(error3.message).toBe('valueName must be type1, type2 or type3, but "value" (string) given') |
44 |
| - }) |
45 |
| -}) |
| 43 | + const error1 = new ValidationError('valueName', 'value', 'type1'); |
| 44 | + const error2 = new ValidationError('valueName', 'value', 'type1', 'type2'); |
| 45 | + const error3 = new ValidationError( |
| 46 | + 'valueName', |
| 47 | + 'value', |
| 48 | + 'type1', |
| 49 | + 'type2', |
| 50 | + 'type3', |
| 51 | + ); |
| 52 | + |
| 53 | + expect(error1.message).toBe( |
| 54 | + 'valueName must be type1, but "value" (string) given', |
| 55 | + ); |
| 56 | + expect(error2.message).toBe( |
| 57 | + 'valueName must be type1 or type2, but "value" (string) given', |
| 58 | + ); |
| 59 | + expect(error3.message).toBe( |
| 60 | + 'valueName must be type1, type2 or type3, but "value" (string) given', |
| 61 | + ); |
| 62 | + }); |
| 63 | +}); |
0 commit comments