From 27896b8e428acc1c5b4d8a24c9f449b387cb4158 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 9 Nov 2016 16:33:19 -0700 Subject: [PATCH] Fixed tests for new users model --- .../coral-admin/src/services/talk-adapter.js | 2 +- tests/models/comment.js | 41 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/client/coral-admin/src/services/talk-adapter.js b/client/coral-admin/src/services/talk-adapter.js index 8122bc709..b187c6791 100644 --- a/client/coral-admin/src/services/talk-adapter.js +++ b/client/coral-admin/src/services/talk-adapter.js @@ -42,7 +42,7 @@ Promise.all([fetch('/api/v1/comments/status/pending'), fetch('/api/v1/comments/s // Update a comment. Now to update a comment we need to send back the whole object const updateComment = (store, comment) => -fetch('/api/v1/comments/${comment._id}/status', { +fetch(`/api/v1/comments/${comment._id}/status`, { method: 'POST', body: JSON.stringify({status: comment.status}) }) diff --git a/tests/models/comment.js b/tests/models/comment.js index b4b8a51ba..27817ccb2 100644 --- a/tests/models/comment.js +++ b/tests/models/comment.js @@ -34,11 +34,13 @@ describe('Comment: models', () => { }]; const users = [{ - id: '123', - display_name: 'Ana', + email: 'stampi@gmail.com', + displayName: 'Stampi', + password: '1Coral!' }, { - id: '456', - display_name: 'Maria', + email: 'sockmonster@gmail.com', + displayName: 'Sockmonster', + password: '2Coral!' }]; const actions = [{ @@ -54,13 +56,12 @@ describe('Comment: models', () => { }]; beforeEach(() => { - return Setting.create(settings).then(() => { - return Comment.create(comments); - }).then(() => { - return User.create(users); - }).then(() => { - return Action.create(actions); - }); + return Promise.all([ + Setting.create(settings), + Comment.create(comments), + User.createLocalUsers(users), + Action.create(actions) + ]); }); describe('#findById()', () => { @@ -74,15 +75,17 @@ describe('Comment: models', () => { describe('#findByAssetId()', () => { it('should find an array of comments by asset id', () => { - return Comment.findByAssetId('123').then((result) => { - expect(result).to.have.length(2); - result.sort((a, b) => { - if (a.body < b.body) {return -1;} - else {return 1;} + return Comment + .findByAssetId('123') + .then((result) => { + expect(result).to.have.length(2); + result.sort((a, b) => { + if (a.body < b.body) {return -1;} + else {return 1;} + }); + expect(result[0]).to.have.property('body', 'comment 10'); + expect(result[1]).to.have.property('body', 'comment 20'); }); - expect(result[0]).to.have.property('body', 'comment 10'); - expect(result[1]).to.have.property('body', 'comment 20'); - }); }); }); describe('#moderationQueue()', () => {