Old-style custom matchers (those which call this.report()) are not supported with the ".not" matcher negation syntax.
This commit is contained in:
parent
4b80a10969
commit
49f295690a
|
@ -513,6 +513,22 @@ describe("jasmine.Matchers", function() {
|
||||||
match(false).not.custom();
|
match(false).not.custom();
|
||||||
expect(lastResult().message).toEqual("Passed.");
|
expect(lastResult().message).toEqual("Passed.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should make old-style custom matchers blow up, but only when negated", function() {
|
||||||
|
spec.addMatchers({
|
||||||
|
custom: function() {
|
||||||
|
this.report();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
match(true).custom();
|
||||||
|
}).not.toThrow();
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
match(true).not.custom();
|
||||||
|
}).toThrow();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("spy matchers >>", function() {
|
describe("spy matchers >>", function() {
|
||||||
|
|
|
@ -18,8 +18,12 @@ jasmine.Matchers.pp = function(str) {
|
||||||
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
||||||
// todo first: report deprecation warning [xw]
|
// todo: report a deprecation warning [xw]
|
||||||
// todo later: throw new Error("As of jasmine 0.xx, custom matchers must be implemented differently -- please see jasmine docs");
|
|
||||||
|
if (this.isNot) {
|
||||||
|
throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
|
||||||
|
}
|
||||||
|
|
||||||
this.reportWasCalled_ = true;
|
this.reportWasCalled_ = true;
|
||||||
var expectationResult = new jasmine.ExpectationResult({
|
var expectationResult = new jasmine.ExpectationResult({
|
||||||
passed: result,
|
passed: result,
|
||||||
|
|
Loading…
Reference in New Issue