Last active
December 31, 2015 13:09
-
-
Save smikes/7991102 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isBasicType(type, value) { | |
return type(value).valueOf() === value; | |
} | |
test('isBasicType works', function () { | |
assert.ok(isBasicType(Boolean, true)); | |
assert.ok(isBasicType(Boolean, false)); | |
assert.ok(isBasicType(Number, 1)); | |
assert.ok(!isBasicType(Boolean, 0)); | |
assert.ok(!isBasicType(Boolean, 1)); | |
assert.ok(!isBasicType(Number, false)); | |
assert.ok(!isBasicType(String, 1)); | |
assert.ok(!isBasicType(Number, '1')); | |
}); | |
test('hardcoded: example rc contains only valid options', function (done) { | |
var options = { | |
foo: Boolean, | |
bar: Number | |
}, | |
example = { | |
foo: true, | |
bar: 3 | |
}, | |
keys; | |
keys = Object.keys(example); | |
keys.forEach(function(opt) { | |
assert.ok(options.hasOwnProperty(opt)); | |
var type = options[opt], | |
value = example[opt]; | |
assert.ok(isBasicType(type, value)); | |
}); | |
done(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment