mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
feat: renderSync, parseAndRenderSync and renderFileSync, see #48
This commit is contained in:
+23
-6
@@ -6,7 +6,7 @@ import * as chaiAsPromised from 'chai-as-promised'
|
||||
use(chaiAsPromised)
|
||||
|
||||
describe('fs', function () {
|
||||
describe('#resolve()', function () {
|
||||
describe('.resolve()', function () {
|
||||
it('should resolve based on root', async function () {
|
||||
const filepath = fs.resolve('/foo', 'bar.html', '.liquid')
|
||||
const expected = path.resolve('/foo/bar.html')
|
||||
@@ -18,23 +18,40 @@ describe('fs', function () {
|
||||
return expect(filepath).to.equal(expected)
|
||||
})
|
||||
})
|
||||
describe('#exists', () => {
|
||||
describe('.existsSync', () => {
|
||||
it('should resolve as false if not exists', () => {
|
||||
expect(fs.existsSync('/foo/bar')).to.be.false
|
||||
})
|
||||
it('should resolve as true if exists', () => {
|
||||
expect(fs.existsSync(__filename)).to.be.true
|
||||
})
|
||||
})
|
||||
describe('.exists', () => {
|
||||
it('should resolve as false if not exists', async () => {
|
||||
const result = await fs.exists('/foo/bar')
|
||||
return expect(result).to.be.false
|
||||
expect(result).to.be.false
|
||||
})
|
||||
it('should resolve as true if exists', async () => {
|
||||
const result = await fs.exists(__filename)
|
||||
return expect(result).to.be.true
|
||||
expect(result).to.be.true
|
||||
})
|
||||
})
|
||||
describe('#readFile', function () {
|
||||
describe('.readFileSync', function () {
|
||||
it('should throw when not exist', function () {
|
||||
return expect(() => fs.readFileSync('/foo/bar')).to.throw('ENOENT')
|
||||
})
|
||||
it('should read content if exists', function () {
|
||||
const content = fs.readFileSync(__filename)
|
||||
expect(content).to.contain('should read content if exists')
|
||||
})
|
||||
})
|
||||
describe('.readFile', function () {
|
||||
it('should throw when not exist', function () {
|
||||
return expect(fs.readFile('/foo/bar')).to.rejectedWith('ENOENT')
|
||||
})
|
||||
it('should read content if exists', async function () {
|
||||
const content = await fs.readFile(__filename)
|
||||
return expect(content).to.contain('should read content if exists')
|
||||
expect(content).to.contain('should read content if exists')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user