Skip to content

Commit

Permalink
run lint ealush#521
Browse files Browse the repository at this point in the history
  • Loading branch information
Moses3301 committed Nov 29, 2020
1 parent a636408 commit 51fbd01
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
50 changes: 25 additions & 25 deletions packages/n4s/src/enforce/compounds/__tests__/allOf.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ describe('allOf validation', () => {
);
});
it('Should succeed when all of the rules applies', () => {
expect(
allOf('test', enforce.isString(), enforce.longerThan(3))
).toBe(true);
expect(allOf('test', enforce.isString(), enforce.longerThan(3))).toBe(
true
);
});
it('Should fail with no rules', () => {
expect(allOf(3)).toBe(true);
Expand All @@ -29,37 +29,37 @@ describe('allOf validation', () => {
}),
})
);

const DisabledAccount = enforce.template(
enforce.loose({
disabled: enforce.equals(true)
disabled: enforce.equals(true),
})
)
);

it('Should validate allof the rules correctly', () => {
enforce(
{ id: 123, name : { first: 'Albert', last: 'Einstein' } ,disabled: true }
).allOf(
User, DisabledAccount
);
enforce({
id: 123,
name: { first: 'Albert', last: 'Einstein' },
disabled: true,
}).allOf(User, DisabledAccount);
});

it('Should throw if one of the rules fail', () =>{
expect( () => {
enforce(
{ id: 123, name : { first: 'Albert', last: 0 } ,disabled: true }
).allOf(
User, DisabledAccount
);
it('Should throw if one of the rules fail', () => {
expect(() => {
enforce({
id: 123,
name: { first: 'Albert', last: 0 },
disabled: true,
}).allOf(User, DisabledAccount);
}).toThrow();

expect(() => {
enforce(
{ id: 123, name : { first: 'Albert', last: 'Einstein' } ,disabled: false }
).allOf(
User, DisabledAccount
);
enforce({
id: 123,
name: { first: 'Albert', last: 'Einstein' },
disabled: false,
}).allOf(User, DisabledAccount);
}).toThrow();
})
});
});
});
2 changes: 0 additions & 2 deletions packages/n4s/src/enforce/compounds/__tests__/anyOf.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ describe('AnyOf validation', () => {
expect(anyOf(5)).toBe(true);
});
});

describe('As part of enforce', () => {
it('Should validate anyof the rules correctly', () => {
enforce(77).anyOf(
enforce.isString(),
enforce.isNumber(),
enforce.isUndefined()
);

expect(() =>
enforce({ test: 4 }).anyOf(enforce.isNumber(), enforce.isUndefined())
).toThrow();
Expand Down
4 changes: 2 additions & 2 deletions packages/n4s/src/enforce/compounds/compounds.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import anyOf from 'anyOf';
import allOf from 'allOf';
import anyOf from 'anyOf';
import isArrayOf from 'isArrayOf';
import optional from 'optional';
import { shape, loose } from 'shape';

export default {
anyOf,
allOf,
anyOf,
isArrayOf,
loose,
optional,
Expand Down

0 comments on commit 51fbd01

Please sign in to comment.