Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test/extend/tag): async function (#3328) #5003

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions test/scripts/extend/tag.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const { spy } = require('sinon');
const Promise = require('bluebird');

describe('Tag', () => {
const Tag = require('../../../lib/extend/tag');
Expand All @@ -19,7 +18,7 @@ describe('Tag', () => {
it('register() - async', async () => {
const tag = new Tag();

tag.register('test', (args, content) => Promise.resolve(args.join(' ')), { async: true });
tag.register('test', async (args, content) => args.join(' '), { async: true });

const result = await tag.render('{% test foo bar %}');
result.should.eql('foo bar');
Expand All @@ -43,7 +42,7 @@ describe('Tag', () => {
it('register() - async block', async () => {
const tag = new Tag();

tag.register('test', (args, content) => Promise.resolve(args.join(' ') + ' ' + content), { ends: true, async: true });
tag.register('test', async (args, content) => args.join(' ') + ' ' + content, { ends: true, async: true });

const str = [
'{% test foo bar %}',
Expand Down Expand Up @@ -81,9 +80,7 @@ describe('Tag', () => {
const tag = new Tag();

tag.register('test', (args, content) => content, {ends: true, async: true});
tag.register('async', (args, content) => {
return Promise.resolve(args.join(' ') + ' ' + content);
}, { ends: true, async: true });
tag.register('async', async (args, content) => args.join(' ') + ' ' + content, { ends: true, async: true });

const str = [
'{% test %}',
Expand Down Expand Up @@ -136,7 +133,7 @@ describe('Tag', () => {
it('unregister()', () => {
const tag = new Tag();

tag.register('test', (args, content) => Promise.resolve(args.join(' ')), {async: true});
tag.register('test', async (args, content) => args.join(' '), {async: true});
tag.unregister('test');

return tag.render('{% test foo bar %}')
Expand Down