Skip to content

Commit

Permalink
tests(n4s): add paritla tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 10, 2021
1 parent 220127b commit e4e2a80
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/n4s/src/modifiers/__tests__/partial.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,28 @@ describe('enforce.partial', () => {
).toThrow();
});
});

it("Should retain rule's original constraints", () => {
expect(
enforce
.shape(
enforce.partial({
username: enforce.isString().longerThan(3),
id: enforce.isNumeric(),
})
)
.run({ username: 'foobar', id: '1', foo: 'bar' })
).toEqual(ruleReturn.failing());

expect(
enforce
.loose(
enforce.partial({
username: enforce.isString().longerThan(3),
id: enforce.isNumeric(),
})
)
.run({ username: 'foobar', id: '1', foo: 'bar' })
).toEqual(ruleReturn.passing());
});
});

0 comments on commit e4e2a80

Please sign in to comment.