Skip to content

Commit

Permalink
Bump sinon to version 4.1.2 (#9283)
Browse files Browse the repository at this point in the history
refs #9178

- adapt major changes
  • Loading branch information
kirrg001 authored Nov 28, 2017
1 parent 9e388ae commit b4b5da2
Show file tree
Hide file tree
Showing 46 changed files with 194 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Subscriber: Routing', function () {
});

before(function () {
sandbox.stub(labs, 'isSet', function (key) {
sandbox.stub(labs, 'isSet').callsFake(function (key) {
if (key === 'subscribers') {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion core/test/functional/routes/channel_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Channel Routes', function () {
before(function (done) {
// Default is always casper. We use the old compatible 1.4 casper theme for these tests. Available in the test content folder.
var originalSettingsCacheGetFn = settingsCache.get;
sandbox.stub(settingsCache, 'get', function (key, options) {
sandbox.stub(settingsCache, 'get').callsFake(function (key, options) {
if (key === 'active_theme') {
return 'casper-1.4';
}
Expand Down
2 changes: 1 addition & 1 deletion core/test/functional/routes/frontend_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ describe('Frontend Routing', function () {
});

it('should not render AMP, when AMP is disabled', function (done) {
sandbox.stub(settingsCache, 'get', function (key, options) {
sandbox.stub(settingsCache, 'get').callsFake(function (key, options) {
if (key === 'amp' && !options) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/api/api_authentication_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Authentication API', function () {

// Stub mail
beforeEach(function () {
sandbox.stub(mail, 'send', function () {
sandbox.stub(mail, 'send').callsFake(function () {
return Promise.resolve();
});
});
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/api/api_invites_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Invites API', function () {
beforeEach(testUtils.setup('invites', 'settings', 'users:roles', 'perms:invite', 'perms:init'));

beforeEach(function () {
sandbox.stub(mail, 'send', function () {
sandbox.stub(mail, 'send').callsFake(function () {
return Promise.resolve();
});
});
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/api/api_posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Post API', function () {
});

beforeEach(function () {
sandbox.stub(settingsCache, 'get', function (key) {
sandbox.stub(settingsCache, 'get').callsFake(function (key) {
return localSettingsCache[key];
});
});
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/api/api_schedules_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe('Schedules API', function () {
}, 500);

// target post to publish was read already, simulate a client request
sandbox.stub(api.posts, 'edit', function () {
sandbox.stub(api.posts, 'edit').callsFake(function () {
var self = this,
args = arguments;

Expand Down
4 changes: 2 additions & 2 deletions core/test/integration/api/api_subscribers_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ describe('Subscribers API', function () {
stub;

beforeEach(function () {
sandbox.stub(fs, 'unlink', function (path, cb) {
sandbox.stub(fs, 'unlink').callsFake(function (path, cb) {
cb();
});
sandbox.stub(apiUtils, 'checkFileExists').returns(true);
stub = sandbox.stub(apiUtils, 'checkFileIsValid').returns(true);
sandbox.stub(serverUtils, 'readCSV', function () {
sandbox.stub(serverUtils, 'readCSV').callsFake(function () {
if (scope.csvError) {
return Promise.reject(new Error('csv'));
}
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/api/api_users_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Users API', function () {
beforeEach(function () {
eventsTriggered = {};

sandbox.stub(events, 'emit', function (eventName, eventObj) {
sandbox.stub(events, 'emit').callsFake(function (eventName, eventObj) {
if (!eventsTriggered[eventName]) {
eventsTriggered[eventName] = [];
}
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/api/redirects_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Redirects API', function () {
beforeEach(testUtils.setup('settings', 'users:roles', 'perms:redirect', 'perms:init'));

beforeEach(function () {
sandbox.stub(mail, 'send', function () {
sandbox.stub(mail, 'send').callsFake(function () {
return Promise.resolve();
});
});
Expand Down
2 changes: 1 addition & 1 deletion core/test/integration/model/base/listeners_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Models: listeners', function () {
beforeEach(testUtils.setup('owner', 'user-token:0'));

beforeEach(function () {
sandbox.stub(events, 'on', function (eventName, callback) {
sandbox.stub(events, 'on').callsFake(function (eventName, callback) {
eventsToRemember[eventName] = callback;
});

Expand Down
14 changes: 7 additions & 7 deletions core/test/integration/model/model_posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('Post Model', function () {

describe('findAll', function () {
beforeEach(function () {
sandbox.stub(settingsCache, 'get', function (key) {
sandbox.stub(settingsCache, 'get').callsFake(function (key) {
return {
permalinks: '/:slug/'
}[key];
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('Post Model', function () {

describe('findPage', function () {
beforeEach(function () {
sandbox.stub(settingsCache, 'get', function (key) {
sandbox.stub(settingsCache, 'get').callsFake(function (key) {
return {
permalinks: '/:slug/'
}[key];
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('Post Model', function () {

describe('findOne', function () {
beforeEach(function () {
sandbox.stub(settingsCache, 'get', function (key) {
sandbox.stub(settingsCache, 'get').callsFake(function (key) {
return {
permalinks: '/:slug/'
}[key];
Expand Down Expand Up @@ -387,7 +387,7 @@ describe('Post Model', function () {
it('can findOne, returning a dated permalink', function (done) {
settingsCache.get.restore();

sandbox.stub(settingsCache, 'get', function (key) {
sandbox.stub(settingsCache, 'get').callsFake(function (key) {
return {
permalinks: '/:year/:month/:day/:slug/'
}[key];
Expand All @@ -411,7 +411,7 @@ describe('Post Model', function () {
beforeEach(function () {
eventsTriggered = {};

sandbox.stub(events, 'emit', function (eventName, eventObj) {
sandbox.stub(events, 'emit').callsFake(function (eventName, eventObj) {
if (!eventsTriggered[eventName]) {
eventsTriggered[eventName] = [];
}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ describe('Post Model', function () {
beforeEach(function () {
eventsTriggered = {};

sandbox.stub(events, 'emit', function (eventName, eventObj) {
sandbox.stub(events, 'emit').callsFake(function (eventName, eventObj) {
if (!eventsTriggered[eventName]) {
eventsTriggered[eventName] = [];
}
Expand Down Expand Up @@ -1402,7 +1402,7 @@ describe('Post Model', function () {
describe('destroy', function () {
beforeEach(function () {
eventsTriggered = {};
sandbox.stub(events, 'emit', function (eventName, eventObj) {
sandbox.stub(events, 'emit').callsFake(function (eventName, eventObj) {
if (!eventsTriggered[eventName]) {
eventsTriggered[eventName] = [];
}
Expand Down
6 changes: 3 additions & 3 deletions core/test/integration/model/model_users_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('User Model', function run() {
it('can find gravatar', function (done) {
var userData = testUtils.DataGenerator.forModel.users[4];

sandbox.stub(gravatar, 'lookup', function (userData) {
sandbox.stub(gravatar, 'lookup').callsFake(function (userData) {
userData.image = 'http://www.gravatar.com/avatar/2fab21a4c4ed88e76add10650c73bae1?d=404';
return Promise.resolve(userData);
});
Expand All @@ -107,7 +107,7 @@ describe('User Model', function run() {
it('can handle no gravatar', function (done) {
var userData = testUtils.DataGenerator.forModel.users[0];

sandbox.stub(gravatar, 'lookup', function (userData) {
sandbox.stub(gravatar, 'lookup').callsFake(function (userData) {
return Promise.resolve(userData);
});

Expand Down Expand Up @@ -171,7 +171,7 @@ describe('User Model', function run() {

beforeEach(function () {
eventsTriggered = {};
sandbox.stub(events, 'emit', function (eventName, eventObj) {
sandbox.stub(events, 'emit').callsFake(function (eventName, eventObj) {
if (!eventsTriggered[eventName]) {
eventsTriggered[eventName] = [];
}
Expand Down
6 changes: 3 additions & 3 deletions core/test/unit/adapters/scheduling/SchedulingDefault_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Scheduling Default Adapter', function () {
}),
allJobs = {};

sandbox.stub(scope.adapter, '_execute', function (nextJobs) {
sandbox.stub(scope.adapter, '_execute').callsFake(function (nextJobs) {
Object.keys(nextJobs).length.should.eql(182);
Object.keys(scope.adapter.allJobs).length.should.eql(1000 - 182);
done();
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Scheduling Default Adapter', function () {
nextJobs = {};

sandbox.stub(scope.adapter, 'run');
sandbox.stub(scope.adapter, '_pingUrl', function () {
sandbox.stub(scope.adapter, '_pingUrl').callsFake(function () {
pinged = pinged + 1;
});

Expand All @@ -132,7 +132,7 @@ describe('Scheduling Default Adapter', function () {
jobsToExecute = {};

sandbox.stub(scope.adapter, 'run');
sandbox.stub(scope.adapter, '_pingUrl', function () {
sandbox.stub(scope.adapter, '_pingUrl').callsFake(function () {
pinged = pinged + 1;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ describe('Scheduling: Post Scheduling', function () {

scope.adapter = new SchedulingDefault();

sandbox.stub(api.schedules, 'getScheduledPosts', function () {
sandbox.stub(api.schedules, 'getScheduledPosts').callsFake(function () {
return Promise.resolve({posts: scope.scheduledPosts});
});

sandbox.stub(events, 'onMany', function (events, stubDone) {
sandbox.stub(events, 'onMany').callsFake(function (events, stubDone) {
events.forEach(function (event) {
scope.events[event] = stubDone;
});
});

sandbox.stub(schedulingUtils, 'createAdapter').returns(Promise.resolve(scope.adapter));

sandbox.stub(models.Client, 'findOne', function () {
sandbox.stub(models.Client, 'findOne').callsFake(function () {
return Promise.resolve(scope.client);
});

Expand Down
12 changes: 6 additions & 6 deletions core/test/unit/api/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ describe('API Utils', function () {

it('should handle an unknown rejection', function (done) {
var testStub = sandbox.stub().returns(new Promise.reject()),
permsStub = sandbox.stub(permissions, 'canThis', function () {
permsStub = sandbox.stub(permissions, 'canThis').callsFake(function () {
return {
testing: {
test: testStub
Expand All @@ -567,7 +567,7 @@ describe('API Utils', function () {
var testStub = sandbox.stub().returns(new Promise.reject(
new errors.NoPermissionError()
)),
permsStub = sandbox.stub(permissions, 'canThis', function () {
permsStub = sandbox.stub(permissions, 'canThis').callsFake(function () {
return {
testing: {
test: testStub
Expand All @@ -593,7 +593,7 @@ describe('API Utils', function () {

it('should handle success', function (done) {
var testStub = sandbox.stub().returns(new Promise.resolve()),
permsStub = sandbox.stub(permissions, 'canThis', function () {
permsStub = sandbox.stub(permissions, 'canThis').callsFake(function () {
return {
testing: {
test: testStub
Expand All @@ -620,7 +620,7 @@ describe('API Utils', function () {

it('should ignore unsafe attrs if none are provided', function (done) {
var testStub = sandbox.stub().returns(new Promise.resolve()),
permsStub = sandbox.stub(permissions, 'canThis', function () {
permsStub = sandbox.stub(permissions, 'canThis').callsFake(function () {
return {
testing: {
test: testStub
Expand All @@ -647,7 +647,7 @@ describe('API Utils', function () {

it('should ignore unsafe attrs if they are provided but not present', function (done) {
var testStub = sandbox.stub().returns(new Promise.resolve()),
permsStub = sandbox.stub(permissions, 'canThis', function () {
permsStub = sandbox.stub(permissions, 'canThis').callsFake(function () {
return {
testing: {
test: testStub
Expand All @@ -674,7 +674,7 @@ describe('API Utils', function () {

it('should pass through unsafe attrs if they DO exist', function (done) {
var testStub = sandbox.stub().returns(new Promise.resolve()),
permsStub = sandbox.stub(permissions, 'canThis', function () {
permsStub = sandbox.stub(permissions, 'canThis').callsFake(function () {
return {
testing: {
test: testStub
Expand Down
2 changes: 1 addition & 1 deletion core/test/unit/apps/private-blogging/middleware_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('Private Blogging', function () {
req.url = req.path = '/robots.txt';
res.writeHead = sandbox.spy();
res.end = sandbox.spy();
sandbox.stub(fs, 'readFile', function (file, cb) {
sandbox.stub(fs, 'readFile').callsFake(function (file, cb) {
cb(null, 'User-agent: * Disallow: /');
});
privateBlogging.filterPrivateRoutes(req, res, next);
Expand Down
29 changes: 14 additions & 15 deletions core/test/unit/auth/oauth_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@ describe('OAuth', function () {
req.client = {
id: 1
};
res.setHeader = {};
res.end = {};

res.setHeader = function () {};
res.end = function () {};

sandbox.stub(models.User, 'check')
.withArgs({email: 'username', password: 'password'}).returns(new Promise.resolve({
.withArgs({email: 'username', password: 'password'}).returns(Promise.resolve({
id: 1
}));

sandbox.stub(authUtils, 'createTokens')
.returns(new Promise.resolve({
.returns(Promise.resolve({
access_token: 'AT',
refresh_token: 'RT',
expires_in: Date.now() + 1000
}));

sandbox.stub(res, 'setHeader', function () {
});
sandbox.stub(res, 'setHeader').callsFake(function () {});

sandbox.stub(res, 'end', function (json) {
sandbox.stub(res, 'end').callsFake(function (json) {
try {
should.exist(json);
json = JSON.parse(json);
Expand Down Expand Up @@ -161,8 +161,8 @@ describe('OAuth', function () {
req.connection = {remoteAddress: '127.0.0.1'};
req.body.grant_type = 'refresh_token';
req.body.refresh_token = 'token';
res.setHeader = {};
res.end = {};
res.setHeader = function () {};
res.end = function () {};

sandbox.stub(models.Refreshtoken, 'findOne')
.withArgs({token: 'token'}).returns(new Promise.resolve({
Expand All @@ -180,10 +180,9 @@ describe('OAuth', function () {
expires_in: Date.now() + 1000
}));

sandbox.stub(res, 'setHeader', function () {
});
sandbox.stub(res, 'setHeader').callsFake(function () {});

sandbox.stub(res, 'end', function (json) {
sandbox.stub(res, 'end').callsFake(function (json) {
try {
should.exist(json);
json = JSON.parse(json);
Expand Down Expand Up @@ -269,7 +268,7 @@ describe('OAuth', function () {
}
}));

sandbox.stub(authUtils, 'createTokens', function () {
sandbox.stub(authUtils, 'createTokens').callsFake(function () {
return Promise.reject(new Error('DB error'));
});

Expand Down Expand Up @@ -318,7 +317,7 @@ describe('OAuth', function () {
expires_in: 10
}));

sandbox.stub(passport, 'authenticate', function (name, options, onSuccess) {
sandbox.stub(passport, 'authenticate').callsFake(function (name, options, onSuccess) {
return function () {
onSuccess(null, user);
};
Expand All @@ -339,7 +338,7 @@ describe('OAuth', function () {
req.body.grant_type = 'authorization_code';
req.body.authorizationCode = '1234';

sandbox.stub(passport, 'authenticate', function (name, options, onSuccess) {
sandbox.stub(passport, 'authenticate').callsFake(function (name, options, onSuccess) {
return function () {
onSuccess(new errors.UnauthorizedError());
};
Expand Down
Loading

0 comments on commit b4b5da2

Please sign in to comment.