Add ReactProps.func

This adds ReactProps.func so people don't need to write the
slightly-more-cryptic ReactProps.instanceOf(Function). We should have
had this all along.
This commit is contained in:
CommitSyncScript
2013-06-06 14:29:44 -07:00
committed by Paul O’Shannessy
parent 259392035d
commit 54d3134da2
2 changed files with 2 additions and 0 deletions
+1
View File
@@ -73,6 +73,7 @@ var Props = {
array: createPrimitiveTypeChecker('array'),
bool: createPrimitiveTypeChecker('boolean'),
func: createPrimitiveTypeChecker('function'),
number: createPrimitiveTypeChecker('number'),
object: createPrimitiveTypeChecker('object'),
string: createPrimitiveTypeChecker('string'),
+1
View File
@@ -56,6 +56,7 @@ describe('Primitive Types', function() {
it("should not throw for valid values", function() {
expect(typeCheck(Props.array, [])).not.toThrow();
expect(typeCheck(Props.bool, false)).not.toThrow();
expect(typeCheck(Props.func, function() {})).not.toThrow();
expect(typeCheck(Props.number, 0)).not.toThrow();
expect(typeCheck(Props.object, {})).not.toThrow();
expect(typeCheck(Props.string, '')).not.toThrow();