Skip to content

Commit

Permalink
refactor(test-helpers-tagcloud): async/await (#4028)
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh authored and SukkaW committed Jan 3, 2020
1 parent 17c0b36 commit 640b91e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test/scripts/helpers/tagcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,25 @@ describe('tagcloud', () => {

const tagcloud = require('../../../lib/plugins/helper/tagcloud').bind(ctx);

before(() => hexo.init().then(() => Post.insert([
{source: 'foo', slug: 'foo'},
{source: 'bar', slug: 'bar'},
{source: 'baz', slug: 'baz'},
{source: 'boo', slug: 'boo'}
])).then(posts => // TODO: Warehouse needs to add a mutex lock when writing data to avoid data sync problem
Promise.each([
before(async () => {
await hexo.init();
const posts = await Post.insert([
{source: 'foo', slug: 'foo'},
{source: 'bar', slug: 'bar'},
{source: 'baz', slug: 'baz'},
{source: 'boo', slug: 'boo'}
]);
// TODO: Warehouse needs to add a mutex lock when writing data to avoid data sync problem
await Promise.all([
['bcd'],
['bcd', 'cde'],
['bcd', 'cde', 'abc'],
['bcd', 'cde', 'abc', 'def']
], (tags, i) => posts[i].setTags(tags))).then(() => {
].map((tags, i) => posts[i].setTags(tags)));

hexo.locals.invalidate();
ctx.site = hexo.locals.toObject();
}));
});

it('default', () => {
const result = tagcloud();
Expand Down

0 comments on commit 640b91e

Please sign in to comment.