|
1 | | -import Morphism, { StrictSchema, morphism, Schema, createSchema, SchemaOptions, SCHEMA_OPTIONS_SYMBOL } from './morphism'; |
| 1 | +import Morphism, { StrictSchema, morphism, Schema, createSchema, SchemaOptions, SCHEMA_OPTIONS_SYMBOL, reporter } from './morphism'; |
2 | 2 | import { User, MockData } from './utils-test'; |
3 | 3 | import { ActionSelector, ActionAggregator } from './types'; |
| 4 | +import { string } from './validation/validators'; |
4 | 5 |
|
5 | 6 | describe('Morphism', () => { |
6 | 7 | const dataToCrunch: MockData[] = [ |
@@ -339,6 +340,19 @@ describe('Morphism', () => { |
339 | 340 | const result = morphism(schema, { s1: 'value' }); |
340 | 341 | expect(result.t1).toEqual('value'); |
341 | 342 | }); |
| 343 | + |
| 344 | + it('should allow to use an action selector without a `fn` specified along with validation options', () => { |
| 345 | + interface Target { |
| 346 | + t1: string; |
| 347 | + } |
| 348 | + const schema = createSchema<Target>({ t1: { path: 's1', type: string } }); |
| 349 | + const result = morphism(schema, { s1: 1234 }); |
| 350 | + const errors = reporter.report(result); |
| 351 | + expect(errors).not.toBeNull(); |
| 352 | + if (errors) { |
| 353 | + expect(errors.length).toBe(1); |
| 354 | + } |
| 355 | + }); |
342 | 356 | }); |
343 | 357 | describe('Function Predicate', function() { |
344 | 358 | it('should support es6 destructuring as function predicate', function() { |
|
0 commit comments