Skip to content

Commit

Permalink
Merge 226db6a into 557ec80
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Feb 15, 2019
2 parents 557ec80 + 226db6a commit 543f5d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions lib/custom-assertions.test.js
@@ -1,5 +1,6 @@
"use strict";

var assert = require("assert");
var sinon = require("sinon");
var referee = require("./referee");

Expand Down Expand Up @@ -162,4 +163,22 @@ describe("custom assertions", function() {

referee.expect("foo").toBeFoo();
});

it("should not throw if Promise is not defined", function() {
// Let sinon restore global.Promise:
sinon.replace(global, "Promise", function() {});
delete global.Promise;

referee.add("custom", {
assert: function(actual) {
return Boolean(actual);
},
assertMessage: "${0} ${0}",
refuteMessage: "${0} ${0}"
});

assert.doesNotThrow(function() {
referee.assert.custom(1);
});
});
});
2 changes: 1 addition & 1 deletion lib/define-assertion.js
Expand Up @@ -50,7 +50,7 @@ function createAssertion(referee, type, name, func, minArgs, messageValues) {

var result = func.apply(ctx, arguments);

if (result instanceof Promise) {
if (typeof Promise === "function" && result instanceof Promise) {
// Here we need to return the promise in order to tell test
// runners that this is an asychronous assertion.
// eslint complains about the return statement, because it is
Expand Down

0 comments on commit 543f5d1

Please sign in to comment.