mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Refactored multiauthor posts suite to async/await
refs https://github.com/TryGhost/Toolbox/issues/268 - I'm about to rewrite it, so made the test suite slightly more readable to keep track of changes easier
This commit is contained in:
parent
5b43b4f40d
commit
b123a9bb77
1 changed files with 13 additions and 17 deletions
|
@ -1660,30 +1660,26 @@ describe('Post Model', function () {
|
||||||
describe('Multiauthor Posts', function () {
|
describe('Multiauthor Posts', function () {
|
||||||
before(testUtils.teardownDb);
|
before(testUtils.teardownDb);
|
||||||
|
|
||||||
after(function () {
|
after(async function () {
|
||||||
return testUtils.teardownDb()
|
await testUtils.teardownDb()
|
||||||
.then(function () {
|
await testUtils.setup('users:roles')();
|
||||||
return testUtils.setup('users:roles')();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
before(testUtils.setup('posts:mu'));
|
before(testUtils.setup('posts:mu'));
|
||||||
|
|
||||||
it('can reassign multiple posts by author', function (done) {
|
it('can reassign multiple posts by author', async function () {
|
||||||
// We're going to delete all posts by user 1
|
// We're going to delete all posts by user 1
|
||||||
const authorData = {id: testUtils.DataGenerator.Content.users[0].id};
|
const authorData = {id: testUtils.DataGenerator.Content.users[0].id};
|
||||||
|
|
||||||
models.Post.findAll({context: {internal: true}}).then(function (found) {
|
const preReassignPosts = await models.Post.findAll({context: {internal: true}});
|
||||||
// There are 10 posts created by posts:mu fixture
|
// There are 10 posts created by posts:mu fixture
|
||||||
found.length.should.equal(10);
|
preReassignPosts.length.should.equal(10);
|
||||||
return models.Post.reassignByAuthor(authorData);
|
|
||||||
}).then(function () {
|
await models.Post.reassignByAuthor(authorData);
|
||||||
return models.Post.findAll({context: {internal: true}});
|
|
||||||
}).then(function (found) {
|
const postReassignPosts = await models.Post.findAll({context: {internal: true}});
|
||||||
// All 10 should remain
|
// All 10 should remain
|
||||||
found.length.should.equal(10);
|
postReassignPosts.length.should.equal(10);
|
||||||
done();
|
|
||||||
}).catch(done);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue