Skip to content

Commit

Permalink
Merge pull request react-bootstrap#941 from AlexKVal/tests
Browse files Browse the repository at this point in the history
Add missed tests for isRequiredForA11y custom validator
  • Loading branch information
AlexKVal committed Jul 5, 2015
2 parents 8abc998 + 4b56692 commit 7f3ec2d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/utils/CustomPropTypesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,21 @@ describe('CustomPropTypes', function() {
validators[2].should.not.have.been.called;
});
});

describe('isRequiredForA11y', function () {
function validate(prop) {
return CustomPropTypes.isRequiredForA11y(React.PropTypes.string)({p: prop}, 'p', 'Component');
}

it('Should validate OK when property is provided', function() {
let err = validate('aria-tag');
assert.notInstanceOf(err, Error);
});

it('Should return custom error message when property is not provided', function() {
let err = validate(null);
assert.instanceOf(err, Error);
assert.include(err.message, 'accessible for users using assistive technologies such as screen readers');
});
});
});

0 comments on commit 7f3ec2d

Please sign in to comment.