Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"use strict";
var referee = require("@sinonjs/referee");
var assert = referee.assert;
if (typeof Worker !== "undefined") {
describe("WebWorker support", function() {
var sentMessage = "whatever";
it("should not crash", function(done) {
var worker = new Worker("/test/webworker/webworker-script.js");
worker.onmessage = function(msg) {
// eslint-disable-next-line no-restricted-syntax
try {
assert.same(msg.data, "worker received:" + sentMessage);
done();
} catch (err) {
done(err);
}
};
"use strict";
/* eslint-disable no-empty-function */
var referee = require("@sinonjs/referee");
var sinonSpy = require("../lib/sinon/spy");
var sinonStub = require("../lib/sinon/stub");
var restoreObject = require("../lib/sinon/restore-object.js");
var assert = referee.assert;
var refute = referee.refute;
describe("restore-object", function() {
it("is defined", function() {
assert.isFunction(restoreObject);
});
it("works on empty objects", function() {
refute.exception(function() {
restoreObject({});
});
});
it("quietly ignores falsy input", function() {
refute.exception(function() {
restoreObject(false);
"use strict";
/* eslint-disable no-empty-function */
var referee = require("@sinonjs/referee");
var sinonSpy = require("../lib/sinon/spy");
var sinonStub = require("../lib/sinon/stub");
var restoreObject = require("../lib/sinon/restore-object.js");
var assert = referee.assert;
var refute = referee.refute;
describe("restore-object", function() {
it("is defined", function() {
assert.isFunction(restoreObject);
});
it("works on empty objects", function() {
refute.exception(function() {
restoreObject({});
});
});
it("quietly ignores falsy input", function() {
refute.exception(function() {
restoreObject(false);
restoreObject(null);
"use strict";
var referee = require("@sinonjs/referee");
var assert = referee.assert;
var refute = referee.refute;
module.exports = function shared(createSpyOrStub) {
it("replaces all methods of an object when no property is given", function() {
var obj = {
func1: function() {
return;
},
func2: function() {
return;
},
func3: function() {
return;
}
};
"use strict";
var referee = require("@sinonjs/referee");
var assert = referee.assert;
var refute = referee.refute;
module.exports = function shared(createSpyOrStub) {
it("replaces all methods of an object when no property is given", function() {
var obj = {
func1: function() {
return;
},
func2: function() {
return;
},
func3: function() {
return;
}
};
createSpyOrStub(obj);
"use strict";
var referee = require("@sinonjs/referee");
referee.add("spy", {
assert: function(obj) {
return obj !== null && typeof obj.calledWith === "function" && !obj.returns;
},
assertMessage: "Expected object ${0} to be a spy function",
refuteMessage: "Expected object ${0} not to be a spy function"
});
referee.add("stub", {
assert: function(obj) {
return obj !== null && typeof obj.calledWith === "function" && typeof obj.returns === "function";
},
assertMessage: "Expected object ${0} to be a stub function",
refuteMessage: "Expected object ${0} not to be a stub function"
});
referee.add("mock", {
assert: function(obj) {
return obj !== null && typeof obj.verify === "function" && typeof obj.expects === "function";
},
assertMessage: "Expected object ${0} to be a mock",
refuteMessage: "Expected object ${0} not to be a mock"
});
referee.add("fakeServer", {
assert: function(obj) {
return obj !== null && typeof obj.calledWith === "function" && !obj.returns;
},
assertMessage: "Expected object ${0} to be a spy function",
refuteMessage: "Expected object ${0} not to be a spy function"
});
referee.add("stub", {
assert: function(obj) {
return obj !== null && typeof obj.calledWith === "function" && typeof obj.returns === "function";
},
assertMessage: "Expected object ${0} to be a stub function",
refuteMessage: "Expected object ${0} not to be a stub function"
});
referee.add("mock", {
assert: function(obj) {
return obj !== null && typeof obj.verify === "function" && typeof obj.expects === "function";
},
assertMessage: "Expected object ${0} to be a mock",
refuteMessage: "Expected object ${0} not to be a mock"
});
referee.add("fakeServer", {
assert: function(obj) {
return (
obj !== null &&
Object.prototype.toString.call(obj.requests) === "[object Array]" &&
typeof obj.respondWith === "function"
);
},
assertMessage: "Expected object ${0} to be a fake server",
refuteMessage: "Expected object ${0} not to be a mock"
});
referee.add("fakeServer", {
assert: function(obj) {
return (
obj !== null &&
Object.prototype.toString.call(obj.requests) === "[object Array]" &&
typeof obj.respondWith === "function"
);
},
assertMessage: "Expected object ${0} to be a fake server",
refuteMessage: "Expected object ${0} not to be a fake server"
});
referee.add("clock", {
assert: function(obj) {
return obj !== null && typeof obj.tick === "function" && typeof obj.setTimeout === "function";
},
assertMessage: "Expected object ${0} to be a clock",
refuteMessage: "Expected object ${0} not to be a clock"
});
"use strict";
var referee = require("@sinonjs/referee");
referee.add("spy", {
assert: function(obj) {
return obj !== null && typeof obj.calledWith === "function" && !obj.returns;
},
assertMessage: "Expected object ${0} to be a spy function",
refuteMessage: "Expected object ${0} not to be a spy function"
});
referee.add("stub", {
assert: function(obj) {
return obj !== null && typeof obj.calledWith === "function" && typeof obj.returns === "function";
},
assertMessage: "Expected object ${0} to be a stub function",
refuteMessage: "Expected object ${0} not to be a stub function"
});
referee.add("mock", {
assert: function(obj) {
return obj !== null && typeof obj.calledWith === "function" && typeof obj.returns === "function";
},
assertMessage: "Expected object ${0} to be a stub function",
refuteMessage: "Expected object ${0} not to be a stub function"
});
referee.add("mock", {
assert: function(obj) {
return obj !== null && typeof obj.verify === "function" && typeof obj.expects === "function";
},
assertMessage: "Expected object ${0} to be a mock",
refuteMessage: "Expected object ${0} not to be a mock"
});
referee.add("fakeServer", {
assert: function(obj) {
return (
obj !== null &&
Object.prototype.toString.call(obj.requests) === "[object Array]" &&
typeof obj.respondWith === "function"
);
},
assertMessage: "Expected object ${0} to be a fake server",
refuteMessage: "Expected object ${0} not to be a fake server"
});
referee.add("clock", {
assert: function(obj) {
return obj !== null && typeof obj.tick === "function" && typeof obj.setTimeout === "function";
},
assertMessage: "Expected object ${0} to be a clock",