Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit d953fff

Browse files
committed
added test for all - isRequired feature
1 parent f9ec727 commit d953fff

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/allSpec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,19 @@ describe('all', function() {
5656

5757
validators[2].should.not.have.been.called;
5858
});
59+
60+
it('always fails when prop value is missing and isRequired is used', function() {
61+
const missingPropName = 'missing';
62+
const allValidator = all(...validators).isRequired;
63+
const expectedErr = new Error(
64+
`Required prop '${missingPropName}' was not specified in '${componentName}'.`
65+
);
66+
67+
const result = allValidator(props, missingPropName, componentName);
68+
expect(result.toString()).to.equal(expectedErr.toString()); // cannot compare values, as we got different Error instances here.
69+
70+
validators[0].should.not.have.been.called;
71+
validators[1].should.not.have.been.called;
72+
validators[2].should.not.have.been.called;
73+
});
5974
});

0 commit comments

Comments
 (0)