Skip to content

Commit

Permalink
refactor(test-helpers-is): async/await (#3957)
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh authored and SukkaW committed Dec 27, 2019
1 parent 5f0090c commit f972a9d
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions test/scripts/helpers/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,74 @@ describe('is', () => {
const hexo = new Hexo(__dirname);
const is = require('../../../lib/plugins/helper/is');

it('is_current', () => {
is.current.call({path: 'index.html', config: hexo.config}).should.be.true;
is.current.call({path: 'tags/index.html', config: hexo.config}).should.be.false;
is.current.call({path: 'index.html', config: hexo.config}, '/').should.be.true;
is.current.call({path: 'index.html', config: hexo.config}, 'index.html').should.be.true;
is.current.call({path: 'tags/index.html', config: hexo.config}, '/').should.be.false;
is.current.call({path: 'tags/index.html', config: hexo.config}, '/index.html').should.be.false;
is.current.call({path: 'index.html', config: hexo.config}, '/', true).should.be.true;
is.current.call({path: 'index.html', config: hexo.config}, '/index.html', true).should.be.true;
is.current.call({path: 'foo/bar', config: hexo.config}, 'foo', true).should.be.false;
is.current.call({path: 'foo/bar', config: hexo.config}, 'foo').should.be.true;
is.current.call({path: 'foo/bar', config: hexo.config}, 'foo/bar').should.be.true;
is.current.call({path: 'foo/bar', config: hexo.config}, 'foo/baz').should.be.false;
it('is_current', async() => {
await is.current.call({path: 'index.html', config: hexo.config}).should.eql(true);
await is.current.call({path: 'tags/index.html', config: hexo.config}).should.eql(false);
await is.current.call({path: 'index.html', config: hexo.config}, '/').should.eql(true);
await is.current.call({path: 'index.html', config: hexo.config}, 'index.html').should.eql(true);
await is.current.call({path: 'tags/index.html', config: hexo.config}, '/').should.eql(false);
await is.current.call({path: 'tags/index.html', config: hexo.config}, '/index.html').should.eql(false);
await is.current.call({path: 'index.html', config: hexo.config}, '/', true).should.eql(true);
await is.current.call({path: 'index.html', config: hexo.config}, '/index.html', true).should.eql(true);
await is.current.call({path: 'foo/bar', config: hexo.config}, 'foo', true).should.eql(false);
await is.current.call({path: 'foo/bar', config: hexo.config}, 'foo').should.eql(true);
await is.current.call({path: 'foo/bar', config: hexo.config}, 'foo/bar').should.eql(true);
await is.current.call({path: 'foo/bar', config: hexo.config}, 'foo/baz').should.eql(false);
});

it('is_home', () => {
is.home.call({page: {__index: true}}).should.be.true;
is.home.call({page: {}}).should.be.false;
it('is_home', async() => {
await is.home.call({page: {__index: true}}).should.eql(true);
await is.home.call({page: {}}).should.eql(false);
});

it('is_post', () => {
is.post.call({page: {__post: true}}).should.be.true;
is.post.call({page: {}}).should.be.false;
it('is_post', async() => {
await is.post.call({page: {__post: true}}).should.eql(true);
await is.post.call({page: {}}).should.eql(false);
});

it('is_page', () => {
is.page.call({page: {__page: true}}).should.be.true;
is.page.call({page: {}}).should.be.false;
it('is_page', async() => {
await is.page.call({page: {__page: true}}).should.eql(true);
await is.page.call({page: {}}).should.eql(false);
});

it('is_archive', () => {
is.archive.call({page: {}}).should.be.false;
is.archive.call({page: {archive: true}}).should.be.true;
is.archive.call({page: {archive: false}}).should.be.false;
it('is_archive', async() => {
await is.archive.call({page: {}}).should.eql(false);
await is.archive.call({page: {archive: true}}).should.eql(true);
await is.archive.call({page: {archive: false}}).should.eql(false);
});

it('is_year', () => {
is.year.call({page: {}}).should.be.false;
is.year.call({page: {archive: true}}).should.be.false;
is.year.call({page: {archive: true, year: 2014}}).should.be.true;
is.year.call({page: {archive: true, year: 2014}}, 2014).should.be.true;
is.year.call({page: {archive: true, year: 2014}}, 2015).should.be.false;
is.year.call({page: {archive: true, year: 2014, month: 10}}).should.be.true;
it('is_year', async() => {
await is.year.call({page: {}}).should.eql(false);
await is.year.call({page: {archive: true}}).should.eql(false);
await is.year.call({page: {archive: true, year: 2014}}).should.eql(true);
await is.year.call({page: {archive: true, year: 2014}}, 2014).should.eql(true);
await is.year.call({page: {archive: true, year: 2014}}, 2015).should.eql(false);
await is.year.call({page: {archive: true, year: 2014, month: 10}}).should.eql(true);
});

it('is_month', () => {
is.month.call({page: {}}).should.be.false;
is.month.call({page: {archive: true}}).should.be.false;
is.month.call({page: {archive: true, year: 2014}}).should.be.false;
is.month.call({page: {archive: true, year: 2014, month: 10}}).should.be.true;
is.month.call({page: {archive: true, year: 2014, month: 10}}, 2014, 10).should.be.true;
is.month.call({page: {archive: true, year: 2014, month: 10}}, 2015, 10).should.be.false;
is.month.call({page: {archive: true, year: 2014, month: 10}}, 2014, 12).should.be.false;
is.month.call({page: {archive: true, year: 2014, month: 10}}, 10).should.be.true;
is.month.call({page: {archive: true, year: 2014, month: 10}}, 12).should.be.false;
it('is_month', async() => {
await is.month.call({page: {}}).should.eql(false);
await is.month.call({page: {archive: true}}).should.eql(false);
await is.month.call({page: {archive: true, year: 2014}}).should.eql(false);
await is.month.call({page: {archive: true, year: 2014, month: 10}}).should.eql(true);
await is.month.call({page: {archive: true, year: 2014, month: 10}}, 2014, 10).should.eql(true);
await is.month.call({page: {archive: true, year: 2014, month: 10}}, 2015, 10).should.eql(false);
await is.month.call({page: {archive: true, year: 2014, month: 10}}, 2014, 12).should.eql(false);
await is.month.call({page: {archive: true, year: 2014, month: 10}}, 10).should.eql(true);
await is.month.call({page: {archive: true, year: 2014, month: 10}}, 12).should.eql(false);
});

it('is_category', () => {
is.category.call({page: {category: 'foo'}}).should.be.true;
is.category.call({page: {category: 'foo'}}, 'foo').should.be.true;
is.category.call({page: {category: 'foo'}}, 'bar').should.be.false;
is.category.call({page: {}}).should.be.false;
it('is_category', async() => {
await is.category.call({page: {category: 'foo'}}).should.eql(true);
await is.category.call({page: {category: 'foo'}}, 'foo').should.eql(true);
await is.category.call({page: {category: 'foo'}}, 'bar').should.eql(false);
await is.category.call({page: {}}).should.eql(false);
});

it('is_tag', () => {
is.tag.call({page: {tag: 'foo'}}).should.be.true;
is.tag.call({page: {tag: 'foo'}}, 'foo').should.be.true;
is.tag.call({page: {tag: 'foo'}}, 'bar').should.be.false;
is.tag.call({page: {}}).should.be.false;
it('is_tag', async() => {
await is.tag.call({page: {tag: 'foo'}}).should.eql(true);
await is.tag.call({page: {tag: 'foo'}}, 'foo').should.eql(true);
await is.tag.call({page: {tag: 'foo'}}, 'bar').should.eql(false);
await is.tag.call({page: {}}).should.eql(false);
});
});

0 comments on commit f972a9d

Please sign in to comment.