Add asymmetric equality tester to match a string against a regexp

- Also move the asymmetric testers into their own dir for easier
  locating.

[#58120558] Fix #243
This commit is contained in:
slackersoft
2014-12-19 12:36:33 -08:00
parent 2472982fe9
commit dfa8a77dc3
11 changed files with 134 additions and 74 deletions

View File

@@ -0,0 +1,46 @@
describe("Any", function() {
it("matches a string", function() {
var any = new j$.Any(String);
expect(any.asymmetricMatch("foo")).toBe(true);
});
it("matches a number", function() {
var any = new j$.Any(Number);
expect(any.asymmetricMatch(1)).toBe(true);
});
it("matches a function", function() {
var any = new j$.Any(Function);
expect(any.asymmetricMatch(function(){})).toBe(true);
});
it("matches an Object", function() {
var any = new j$.Any(Object);
expect(any.asymmetricMatch({})).toBe(true);
});
it("matches a Boolean", function() {
var any = new j$.Any(Boolean);
expect(any.asymmetricMatch(true)).toBe(true);
});
it("matches another constructed object", function() {
var Thing = function() {},
any = new j$.Any(Thing);
expect(any.asymmetricMatch(new Thing())).toBe(true);
});
it("jasmineToString's itself", function() {
var any = new j$.Any(Number);
expect(any.jasmineToString()).toMatch('<jasmine.any');
expect(any.jasmineToString()).toMatch('Number');
});
});