From 4b566921d9803941306aad1b18cf2acf7d524746 Mon Sep 17 00:00:00 2001 From: AlexKVal Date: Sun, 5 Jul 2015 14:54:16 +0300 Subject: [PATCH] Add missed tests for isRequiredForA11y custom validator --- test/utils/CustomPropTypesSpec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/utils/CustomPropTypesSpec.js b/test/utils/CustomPropTypesSpec.js index ef6d8e152e..4254569ea8 100644 --- a/test/utils/CustomPropTypesSpec.js +++ b/test/utils/CustomPropTypesSpec.js @@ -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'); + }); + }); });