0
Fork 0
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:
Naz 2022-04-26 16:52:44 +08:00 committed by Daniel Lockyer
parent 5b43b4f40d
commit b123a9bb77
No known key found for this signature in database
GPG key ID: D21186F0B47295AD

View file

@ -1660,30 +1660,26 @@ describe('Post Model', function () {
describe('Multiauthor Posts', function () {
before(testUtils.teardownDb);
after(function () {
return testUtils.teardownDb()
.then(function () {
return testUtils.setup('users:roles')();
});
after(async function () {
await testUtils.teardownDb()
await testUtils.setup('users:roles')();
});
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
const authorData = {id: testUtils.DataGenerator.Content.users[0].id};
models.Post.findAll({context: {internal: true}}).then(function (found) {
// There are 10 posts created by posts:mu fixture
found.length.should.equal(10);
return models.Post.reassignByAuthor(authorData);
}).then(function () {
return models.Post.findAll({context: {internal: true}});
}).then(function (found) {
// All 10 should remain
found.length.should.equal(10);
done();
}).catch(done);
const preReassignPosts = await models.Post.findAll({context: {internal: true}});
// There are 10 posts created by posts:mu fixture
preReassignPosts.length.should.equal(10);
await models.Post.reassignByAuthor(authorData);
const postReassignPosts = await models.Post.findAll({context: {internal: true}});
// All 10 should remain
postReassignPosts.length.should.equal(10);
});
});