mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
chore(TypeScript): fix unit tests and coverage
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
--require ts-node/register
|
||||
--require tsconfig-paths/register
|
||||
@@ -12,7 +12,7 @@ describe('LiquidOptions#trimming', function () {
|
||||
})
|
||||
it('should respect trim_tag_right', async function () {
|
||||
const engine = new Liquid({ trim_tag_right: true })
|
||||
const html = engine.parseAndRender('\t{%if true%}foo{%endif%} \n')
|
||||
const html = await engine.parseAndRender('\t{%if true%}foo{%endif%} \n')
|
||||
return expect(html).to.equal('\tfoo')
|
||||
})
|
||||
it('should not trim value', async function () {
|
||||
|
||||
+20
-5
@@ -1,13 +1,28 @@
|
||||
import { resolve } from '../../src/parser/template'
|
||||
import * as mock from 'mock-fs'
|
||||
import { expect } from 'chai'
|
||||
import * as path from 'path'
|
||||
import { fs } from 'src/parser/template'
|
||||
import { expect, use } from 'chai'
|
||||
import * as chaiAsPromised from 'chai-as-promised'
|
||||
|
||||
use(chaiAsPromised)
|
||||
|
||||
describe('template', function () {
|
||||
let readFile, stat
|
||||
before(function () {
|
||||
mock({
|
||||
'/foo/bar.html': 'bar'
|
||||
})
|
||||
readFile = fs.readFile
|
||||
stat = fs.stat
|
||||
fs.readFile = async function (file) {
|
||||
if (file === '/foo/bar.html') return 'bar'
|
||||
throw new Error('NOENT')
|
||||
}
|
||||
fs.stat = async function (file) {
|
||||
if (file === '/foo/bar.html') return { type: 'file' }
|
||||
throw new Error('NOENT')
|
||||
}
|
||||
})
|
||||
after(function () {
|
||||
fs.readFile = readFile
|
||||
fs.stat = stat
|
||||
})
|
||||
describe('#resolve()', function () {
|
||||
it('should resolve based on root', async function () {
|
||||
|
||||
@@ -47,7 +47,8 @@ describe('error', function () {
|
||||
it('should contain stack in err.stack', async function () {
|
||||
const err = await expect(engine.parseAndRender('{% . a %}')).be.rejected
|
||||
expect(err.message).to.contain('illegal tag syntax')
|
||||
expect(err.stack).to.contain('at Object.parse')
|
||||
console.log(err.stack)
|
||||
expect(err.stack).to.contain('at Liquid.parse')
|
||||
})
|
||||
describe('captureStackTrace compatibility', function () {
|
||||
const captureStackTrace = Error.captureStackTrace
|
||||
|
||||
@@ -52,9 +52,9 @@ describe('util/promise', function () {
|
||||
.then(() => expect(spy).to.not.have.been.called)
|
||||
})
|
||||
})
|
||||
describe('.mapSeries()', function () {
|
||||
describe('.mapSeries()', async function () {
|
||||
it('should resolve when all resolved', async function () {
|
||||
const result = P.mapSeries(
|
||||
const result = await P.mapSeries(
|
||||
['first', 'second', 'third'],
|
||||
item => Promise.resolve(item)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user