Skip to content

Commit

Permalink
refactor(test-open_graph): async/await (#3995)
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh authored and SukkaW committed Jan 7, 2020
1 parent e308f3f commit 4a978a7
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions test/scripts/helpers/open_graph.js
Expand Up @@ -21,32 +21,36 @@ describe('open_graph', () => {
return hexo.init();
});

it('default', () => {
Post.insert({
it('default', async () => {
let post = await Post.insert({
source: 'foo.md',
slug: 'bar'
}).then(post => post.setTags(['optimize', 'web'])
.thenReturn(Post.findById(post._id))).then(post => {
openGraph.call({
page: post,
config: hexo.config,
is_post: isPost
}).should.eql([
meta({property: 'og:type', content: 'website'}),
meta({property: 'og:title', content: hexo.config.title}),
meta({property: 'og:url'}),
meta({property: 'og:site_name', content: hexo.config.title}),
meta({property: 'og:locale', content: 'en_US'}),
meta({property: 'article:published_time', content: post.date.toISOString()}),
meta({property: 'article:modified_time', content: post.updated.toISOString()}),
meta({property: 'article:author', content: hexo.config.author}),
meta({property: 'article:tag', content: 'optimize'}),
meta({property: 'article:tag', content: 'web'}),
meta({name: 'twitter:card', content: 'summary'})
].join('\n'));

return Post.removeById(post._id);
});
await post.setTags(['optimize', 'web']);

post = await Post.findById(post._id);

const result = openGraph.call({
page: post,
config: hexo.config,
is_post: isPost
});

result.should.eql([
meta({property: 'og:type', content: 'website'}),
meta({property: 'og:title', content: hexo.config.title}),
meta({property: 'og:url'}),
meta({property: 'og:site_name', content: hexo.config.title}),
meta({property: 'og:locale', content: 'en_US'}),
meta({property: 'article:published_time', content: post.date.toISOString()}),
meta({property: 'article:modified_time', content: post.updated.toISOString()}),
meta({property: 'article:author', content: hexo.config.author}),
meta({property: 'article:tag', content: 'optimize'}),
meta({property: 'article:tag', content: 'web'}),
meta({name: 'twitter:card', content: 'summary'})
].join('\n'));

await Post.removeById(post._id);
});

it('title - page', () => {
Expand Down

0 comments on commit 4a978a7

Please sign in to comment.