mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
Merge pull request #3519 from jaswilli/tests-undefined-key
Fix tests to ensure correct post is being checked
This commit is contained in:
commit
6d3f00f543
1 changed files with 16 additions and 5 deletions
|
@ -21,6 +21,10 @@ describe('Post Model', function () {
|
|||
|
||||
should.exist(PostModel);
|
||||
|
||||
function extractFirstPost(posts) {
|
||||
return _.filter(posts, { id: 1 })[0];
|
||||
}
|
||||
|
||||
function checkFirstPostData(firstPost) {
|
||||
should.not.exist(firstPost.author_id);
|
||||
firstPost.author.should.be.an.Object;
|
||||
|
@ -54,8 +58,14 @@ describe('Post Model', function () {
|
|||
.then(function (results) {
|
||||
should.exist(results);
|
||||
results.length.should.be.above(0);
|
||||
firstPost = results.models[0].toJSON();
|
||||
checkFirstPostData(firstPost);
|
||||
posts = results.models.map(function (model) {
|
||||
return model.toJSON();
|
||||
});
|
||||
|
||||
// the first post in the result is not always the post at
|
||||
// position 0 in the fixture data so we need to use extractFirstPost
|
||||
// to get the post with id: 1
|
||||
checkFirstPostData(extractFirstPost(posts));
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
|
@ -86,9 +96,10 @@ describe('Post Model', function () {
|
|||
results.meta.pagination.pages.should.equal(1);
|
||||
results.posts.length.should.equal(4);
|
||||
|
||||
firstPost = results.posts[0];
|
||||
|
||||
checkFirstPostData(firstPost);
|
||||
// the first post in the result is not always the post at
|
||||
// position 0 in the fixture data so we need to use extractFirstPost
|
||||
// to get the post with id: 1
|
||||
checkFirstPostData(extractFirstPost(results.posts));
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
|
|
Loading…
Reference in a new issue