chore(TypeScript): fix unit tests and coverage

This commit is contained in:
harttle
2019-02-17 20:46:33 +08:00
parent fc9ebdb90f
commit aa49b4f117
8 changed files with 43 additions and 19 deletions
+20 -5
View File
@@ -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 () {