Skip to content

Commit 7f3ec2d

Browse files
committed
Merge pull request react-bootstrap#941 from AlexKVal/tests
Add missed tests for isRequiredForA11y custom validator
2 parents 8abc998 + 4b56692 commit 7f3ec2d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/utils/CustomPropTypesSpec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,21 @@ describe('CustomPropTypes', function() {
167167
validators[2].should.not.have.been.called;
168168
});
169169
});
170+
171+
describe('isRequiredForA11y', function () {
172+
function validate(prop) {
173+
return CustomPropTypes.isRequiredForA11y(React.PropTypes.string)({p: prop}, 'p', 'Component');
174+
}
175+
176+
it('Should validate OK when property is provided', function() {
177+
let err = validate('aria-tag');
178+
assert.notInstanceOf(err, Error);
179+
});
180+
181+
it('Should return custom error message when property is not provided', function() {
182+
let err = validate(null);
183+
assert.instanceOf(err, Error);
184+
assert.include(err.message, 'accessible for users using assistive technologies such as screen readers');
185+
});
186+
});
170187
});

0 commit comments

Comments
 (0)