From 7ccd0cb1e550c443e57af9902ffd9d7c3cc75aac Mon Sep 17 00:00:00 2001 From: Jun Yang Date: Mon, 5 Mar 2018 01:20:43 +0800 Subject: [PATCH] fix: branch coverage --- package.json | 5 +++-- test/tags/include.js | 10 ++++++++++ test/tags/layout.js | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 59acfec28..2f1c0f119 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "lint": "eslint .", "test": "mocha --recursive", - "coverage": "NODE_ENV=test istanbul cover --report html ./node_modules/mocha/bin/_mocha -- -R spec --recursive", - "lcov": "NODE_ENV=test istanbul cover --report lcovonly ./node_modules/mocha/bin/_mocha -- -R spec --recursive", + "coverage": "cross-env NODE_ENV=test istanbul cover --report html ./node_modules/mocha/bin/_mocha -- -R spec --recursive", + "lcov": "cross-env NODE_ENV=test istanbul cover --report lcovonly ./node_modules/mocha/bin/_mocha -- -R spec --recursive", "dist": "make dist", "preversion": "npm run lint && npm test", "version": "npm run dist && git add -A dist", @@ -48,6 +48,7 @@ "chai": "^4.1.2", "chai-as-promised": "^7.1.1", "coveralls": "^3.0.0", + "cross-env": "^5.1.3", "eslint": "^4.8.0", "eslint-config-standard": "^10.2.1", "eslint-plugin-import": "^2.7.0", diff --git a/test/tags/include.js b/test/tags/include.js index 9f0d8d1c0..824698cf9 100644 --- a/test/tags/include.js +++ b/test/tags/include.js @@ -24,6 +24,16 @@ describe('tags/include', function () { .eventually.equal('barfoobar') }) + it('should throw when not specified', function () { + mock({ + '/parent.html': '{%include%}' + }) + return liquid.renderFile('/parent.html').catch(function (e) { + expect(e.name).to.equal('RenderError') + expect(e.message).to.match(/cannot include with empty filename/) + }) + }) + it('should throw when not exist', function () { mock({ '/parent.html': '{%include not-exist%}' diff --git a/test/tags/layout.js b/test/tags/layout.js index 652ef6622..8804e306a 100644 --- a/test/tags/layout.js +++ b/test/tags/layout.js @@ -24,6 +24,15 @@ describe('tags/layout', function () { return expect(liquid.parseAndRender(src)).to .be.rejectedWith(/tag {%block%} not closed/) }) + it('should throw when filename not specified', function () { + mock({ + '/parent.html': '{%layout%}' + }) + return liquid.renderFile('/parent.html').catch(function (e) { + expect(e.name).to.equal('RenderError') + expect(e.message).to.match(/cannot apply layout with empty filename/) + }) + }) describe('anonymous block', function () { it('should handle anonymous block', function () { mock({