mirror of
https://github.com/CryptKeeperZK/ejs.git
synced 2026-01-09 07:27:56 -05:00
Add test for async
This commit is contained in:
22
test/ejs.js
22
test/ejs.js
@@ -118,6 +118,28 @@ suite('ejs.compile(str, options)', function () {
|
||||
assert.equal(ejs.render(fixture('strict.ejs'), {}, {strict: true}), 'true');
|
||||
});
|
||||
|
||||
test('can compile to an async function', function (done) {
|
||||
try {
|
||||
eval('(async function() {})');
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
return;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
ejs.compile('<%= await "Hi" %>', {async: true})().then(function (value) {
|
||||
try {
|
||||
assert.equal(value, 'Hi');
|
||||
} catch (e) {
|
||||
done(e);
|
||||
return;
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('client mode', function () {
|
||||
|
||||
Reference in New Issue
Block a user