Skip to content

Commit

Permalink
deps: should@8.2.1
Browse files Browse the repository at this point in the history
closes #6448
-upgraded should.js to the latest version (8.2.1)
-Changed the tests so that they comply with the breaking changes introduced in the new version of should.js
-Installs the package should-http so should.be.json() can be used
-Installs the package should-sinon so that should.be.calledOnce() can be used
  • Loading branch information
cameronviner committed Feb 9, 2016
1 parent 7bb153a commit faba83d
Show file tree
Hide file tree
Showing 60 changed files with 1,086 additions and 1,080 deletions.
6 changes: 3 additions & 3 deletions core/test/functional/module/module_spec.js
Expand Up @@ -43,9 +43,9 @@ describe('Module', function () {
it('should have start/stop/restart functions', function (done) {
ghost().then(function (ghostServer) {
should.exist(ghostServer);
ghostServer.start.should.be.a.Function;
ghostServer.restart.should.be.a.Function;
ghostServer.stop.should.be.a.Function;
ghostServer.start.should.be.a.Function();
ghostServer.restart.should.be.a.Function();
ghostServer.stop.should.be.a.Function();

done();
}).catch(done);
Expand Down
6 changes: 4 additions & 2 deletions core/test/functional/routes/api/error_spec.js
Expand Up @@ -12,6 +12,8 @@ var supertest = require('supertest'),
ghost = require('../../../../../core'),
request;

require('should-http');

describe('Unauthorized', function () {
before(function (done) {
ghost().then(function (ghostServer) {
Expand All @@ -38,9 +40,9 @@ describe('Unauthorized', function () {
}

should.not.exist(res.headers['x-cache-invalidate']);
res.should.be.json;
res.should.be.json();
var jsonResponse = res.body;
jsonResponse.should.exist;
should.exist(jsonResponse);
// TODO: testUtils.API.checkResponseValue(jsonResponse, ['error']);
done();
});
Expand Down
8 changes: 4 additions & 4 deletions core/test/functional/routes/api/notifications_spec.js
Expand Up @@ -2,7 +2,7 @@
/*jshint expr:true*/
var testUtils = require('../../../utils'),
supertest = require('supertest'),

should = require('should'),
ghost = require('../../../../../core'),

request;
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('Notifications API', function () {

var jsonResponse = res.body;

jsonResponse.notifications.should.exist;
should.exist(jsonResponse.notifications);

testUtils.API.checkResponse(jsonResponse.notifications[0], 'notification');

Expand Down Expand Up @@ -85,7 +85,7 @@ describe('Notifications API', function () {
var location = res.headers.location,
jsonResponse = res.body;

jsonResponse.notifications.should.exist;
should.exist(jsonResponse.notifications);
testUtils.API.checkResponse(jsonResponse.notifications[0], 'notification');

jsonResponse.notifications[0].type.should.equal(newNotification.type);
Expand All @@ -105,7 +105,7 @@ describe('Notifications API', function () {
// a delete returns a JSON object containing the notification
// we just deleted.
var deleteResponse = res.body;
deleteResponse.notifications.should.exist;
should.exist(deleteResponse.notifications);
deleteResponse.notifications[0].type.should.equal(newNotification.type);
deleteResponse.notifications[0].message.should.equal(newNotification.message);
deleteResponse.notifications[0].status.should.equal(newNotification.status);
Expand Down
154 changes: 77 additions & 77 deletions core/test/functional/routes/api/posts_spec.js

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions core/test/functional/routes/api/public_api_spec.js
Expand Up @@ -59,7 +59,7 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.posts.should.exist;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
Expand All @@ -83,7 +83,7 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.posts.should.exist;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(5);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
Expand All @@ -107,7 +107,7 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.tags.should.exist;
should.exist(jsonResponse.tags);
testUtils.API.checkResponse(jsonResponse, 'tags');
jsonResponse.tags.should.have.length(15);
testUtils.API.checkResponse(jsonResponse.tags[0], 'tag');
Expand All @@ -128,7 +128,7 @@ describe('Public API', function () {
}
should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.tags.should.exist;
should.exist(jsonResponse.tags);
testUtils.API.checkResponse(jsonResponse, 'tags');
jsonResponse.tags.should.have.length(56);
testUtils.API.checkResponse(jsonResponse.tags[0], 'tag');
Expand All @@ -150,7 +150,7 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.tags.should.exist;
should.exist(jsonResponse.tags);
testUtils.API.checkResponse(jsonResponse, 'tags');
jsonResponse.tags.should.have.length(4);
testUtils.API.checkResponse(jsonResponse.tags[0], 'tag');
Expand All @@ -172,8 +172,8 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.errors.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.errors);
testUtils.API.checkResponseValue(jsonResponse.errors[0], ['message', 'errorType']);
done();
});
Expand All @@ -192,8 +192,8 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.errors.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.errors);
testUtils.API.checkResponseValue(jsonResponse.errors[0], ['message', 'errorType']);
done();
});
Expand All @@ -212,8 +212,8 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.errors.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.errors);
testUtils.API.checkResponseValue(jsonResponse.errors[0], ['message', 'errorType']);
done();
});
Expand All @@ -232,8 +232,8 @@ describe('Public API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.errors.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.errors);
testUtils.API.checkResponseValue(jsonResponse.errors[0], ['message', 'errorType']);
done();
});
Expand Down
24 changes: 12 additions & 12 deletions core/test/functional/routes/api/settings_spec.js
Expand Up @@ -44,7 +44,7 @@ describe('Settings API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
should.exist(jsonResponse);

testUtils.API.checkResponse(jsonResponse, 'settings');
done();
Expand All @@ -65,12 +65,12 @@ describe('Settings API', function () {
should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;

jsonResponse.should.exist;
jsonResponse.settings.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.settings);

testUtils.API.checkResponseValue(jsonResponse.settings[0], ['id', 'uuid', 'key', 'value', 'type', 'created_at', 'created_by', 'updated_at', 'updated_by']);
jsonResponse.settings[0].key.should.eql('title');
testUtils.API.isISO8601(jsonResponse.settings[0].created_at).should.be.true;
testUtils.API.isISO8601(jsonResponse.settings[0].created_at).should.be.true();
done();
});
});
Expand All @@ -88,8 +88,8 @@ describe('Settings API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.errors.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.errors);
testUtils.API.checkResponseValue(jsonResponse.errors[0], ['message', 'errorType']);
done();
});
Expand All @@ -113,8 +113,8 @@ describe('Settings API', function () {
]
};

jsonResponse.should.exist;
jsonResponse.settings.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.settings);

request.put(testUtils.API.getApiQuery('settings/'))
.set('Authorization', 'Bearer ' + accesstoken)
Expand All @@ -129,7 +129,7 @@ describe('Settings API', function () {

var putBody = res.body;
res.headers['x-cache-invalidate'].should.eql('/*');
putBody.should.exist;
should.exist(putBody);
putBody.settings[0].value.should.eql(changedValue);
testUtils.API.checkResponse(putBody, 'settings');
done();
Expand All @@ -149,7 +149,7 @@ describe('Settings API', function () {

var jsonResponse = res.body,
changedValue = 'Ghost changed';
jsonResponse.should.exist;
should.exist(jsonResponse);
jsonResponse.title = changedValue;

request.put(testUtils.API.getApiQuery('settings/'))
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('Settings API', function () {

var jsonResponse = res.body,
newValue = 'new value';
jsonResponse.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.settings);
jsonResponse.settings = [{key: 'testvalue', value: newValue}];

Expand All @@ -196,7 +196,7 @@ describe('Settings API', function () {

jsonResponse = res.body;
should.not.exist(res.headers['x-cache-invalidate']);
jsonResponse.errors.should.exist;
should.exist(jsonResponse.errors);
testUtils.API.checkResponseValue(jsonResponse.errors[0], ['message', 'errorType']);
done();
});
Expand Down
18 changes: 9 additions & 9 deletions core/test/functional/routes/api/slugs_spec.js
Expand Up @@ -43,8 +43,8 @@ describe('Slug API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.slugs.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.slugs);
jsonResponse.slugs.should.have.length(1);
testUtils.API.checkResponse(jsonResponse.slugs[0], 'slug');
jsonResponse.slugs[0].slug.should.equal('a-post-title');
Expand All @@ -66,8 +66,8 @@ describe('Slug API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.slugs.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.slugs);
jsonResponse.slugs.should.have.length(1);
testUtils.API.checkResponse(jsonResponse.slugs[0], 'slug');
jsonResponse.slugs[0].slug.should.equal('atag');
Expand All @@ -89,8 +89,8 @@ describe('Slug API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.slugs.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.slugs);
jsonResponse.slugs.should.have.length(1);
testUtils.API.checkResponse(jsonResponse.slugs[0], 'slug');
jsonResponse.slugs[0].slug.should.equal('user-name');
Expand All @@ -112,8 +112,8 @@ describe('Slug API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.slugs.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.slugs);
jsonResponse.slugs.should.have.length(1);
testUtils.API.checkResponse(jsonResponse.slugs[0], 'slug');
jsonResponse.slugs[0].slug.should.equal('cool-app');
Expand All @@ -134,7 +134,7 @@ describe('Slug API', function () {
}

var jsonResponse = res.body;
jsonResponse.should.not.exist;
should.exist(jsonResponse.errors);

done();
});
Expand Down
6 changes: 3 additions & 3 deletions core/test/functional/routes/api/tags_spec.js
Expand Up @@ -43,11 +43,11 @@ describe('Tag API', function () {

should.not.exist(res.headers['x-cache-invalidate']);
var jsonResponse = res.body;
jsonResponse.should.exist;
jsonResponse.tags.should.exist;
should.exist(jsonResponse);
should.exist(jsonResponse.tags);
jsonResponse.tags.should.have.length(6);
testUtils.API.checkResponse(jsonResponse.tags[0], 'tag');
testUtils.API.isISO8601(jsonResponse.tags[0].created_at).should.be.true;
testUtils.API.isISO8601(jsonResponse.tags[0].created_at).should.be.true();

done();
});
Expand Down

0 comments on commit faba83d

Please sign in to comment.