Add anything matcher to match any value that is neither null or undefined

[finish #58117878] Fix #186
This commit is contained in:
slackersoft
2014-12-17 12:58:47 -08:00
parent bfcd8b046d
commit 482f4d62fc
5 changed files with 69 additions and 0 deletions

38
spec/core/AnythingSpec.js Normal file
View File

@@ -0,0 +1,38 @@
describe("Anything", function() {
it("matches a string", function() {
var anything = new j$.Anything();
expect(anything.asymmetricMatch('foo')).toBe(true);
});
it("matches a number", function() {
var anything = new j$.Anything();
expect(anything.asymmetricMatch(42)).toBe(true);
});
it("matches an object", function() {
var anything = new j$.Anything();
expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
});
it("matches an array", function() {
var anything = new j$.Anything();
expect(anything.asymmetricMatch([1,2,3])).toBe(true);
});
it("doesn't match undefined", function() {
var anything = new j$.Anything();
expect(anything.asymmetricMatch()).toBe(false);
expect(anything.asymmetricMatch(undefined)).toBe(false);
});
it("doesn't match null", function() {
var anything = new j$.Anything();
expect(anything.asymmetricMatch(null)).toBe(false);
});
});