chore(TypeScript): remove mock-fs

This commit is contained in:
harttle
2019-02-17 21:37:13 +08:00
parent aa49b4f117
commit f432aade6a
11 changed files with 57 additions and 57 deletions
+4 -18
View File
@@ -1,29 +1,15 @@
import { resolve } from '../../src/parser/template'
import * as path from 'path'
import { fs } from 'src/parser/template'
import { expect, use } from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import { mock, restore } from '../stub/mockfs'
use(chaiAsPromised)
describe('template', function () {
let readFile, stat
before(function () {
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
})
before(() => mock({ '/foo/bar.html': 'bar' }))
after(restore)
describe('#resolve()', function () {
it('should resolve based on root', async function () {
const filepath = await resolve('bar.html', '/foo', { root: [] })