Skip to content

Commit 1ebaa57

Browse files
committed
feat(schema): ActionSelector can be used with validation options
1 parent 7ef14d2 commit 1ebaa57

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/morphism.spec.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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';
22
import { User, MockData } from './utils-test';
33
import { ActionSelector, ActionAggregator } from './types';
4+
import { string } from './validation/validators';
45

56
describe('Morphism', () => {
67
const dataToCrunch: MockData[] = [
@@ -339,6 +340,19 @@ describe('Morphism', () => {
339340
const result = morphism(schema, { s1: 'value' });
340341
expect(result.t1).toEqual('value');
341342
});
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+
});
342356
});
343357
describe('Function Predicate', function() {
344358
it('should support es6 destructuring as function predicate', function() {

0 commit comments

Comments
 (0)