|
1 | 1 | import { createField } from './create-field'; |
| 2 | +import { StringConstraints } from '../string-field'; |
2 | 3 |
|
3 | 4 | describe('createField()', () => { |
4 | 5 | it('should return expected field shape when specified a valid argument', () => { |
5 | 6 | const type = 'string'; |
6 | | - const name = 'fieldName'; |
| 7 | + const name = 'field'; |
7 | 8 |
|
8 | 9 | // Supplied constraints object. |
9 | | - const constraints = { minLength: 0 }; |
| 10 | + const constraints: StringConstraints = { minLength: 0, scalar: 'string' }; |
10 | 11 |
|
11 | 12 | // Supplied create field options. |
12 | 13 | const options = { pluralName: 'fields' }; |
13 | 14 |
|
14 | | - expect(createField(type, name, constraints, options)).toEqual({ |
| 15 | + const result = createField(type, name, constraints, options); |
| 16 | + |
| 17 | + expect(result).toEqual({ |
15 | 18 | type, |
16 | 19 | name, |
| 20 | + scalar: 'string', |
17 | 21 | pluralName: 'fields', |
18 | 22 | minLength: 0, |
19 | 23 | }); |
20 | 24 | }); |
21 | 25 |
|
22 | 26 | it('should generate a plural of the provided name', () => { |
23 | | - expect(createField('string', 'name', {}, {}).pluralName).toBe('names'); |
| 27 | + const type = 'string'; |
| 28 | + const name = 'field'; |
| 29 | + |
| 30 | + // Supplied constraints object. |
| 31 | + const constraints: StringConstraints = { scalar: 'string' }; |
| 32 | + |
| 33 | + const result = createField(type, name, constraints); |
| 34 | + |
| 35 | + expect(result.pluralName).toEqual('fields'); |
24 | 36 | }); |
25 | 37 | }); |
0 commit comments