refactor: use promise.mapSeries

This commit is contained in:
harttle
2016-11-01 22:24:56 +08:00
parent f8269f4d20
commit 951225fb75
13 changed files with 103 additions and 124 deletions
+4 -3
View File
@@ -6,18 +6,19 @@ chai.use(require("chai-as-promised"));
describe('tags/capture', function() {
var liquid = Liquid();
it('should support capture 1', function() {
it('should support capture', function() {
var src = '{% capture f %}{{"a" | capitalize}}{%endcapture%}{{f}}';
return expect(liquid.parseAndRender(src))
.to.eventually.equal('A');
});
it('should support capture 2', function() {
it('should throw on invalid identifier', function() {
var src = '{% capture = %}{%endcapture%}';
return expect(liquid.parseAndRender(src))
.to.be.rejectedWith(/= not valid identifier/);
});
it('should throw when for capture closed', function() {
it('should throw when capture not closed', function() {
var src = '{%capture c%}{{c}}';
return expect(liquid.parseAndRender(src))
.to.be.rejectedWith(/tag .* not closed/);
+2 -4
View File
@@ -46,12 +46,10 @@ describe('tags/for', function() {
it('should support for with continue', function() {
var src = '{% for i in (1..5) %}' +
'{% if i == 4 %}{% continue %}' +
'{% else %}{{ i }}' +
'{% endif %}' +
'{{i}}{% continue %}after' +
'{% endfor %}';
return expect(liquid.parseAndRender(src, ctx))
.to.eventually.equal('1235');
.to.eventually.equal('12345');
});
it('should support for with break', function() {
src = '{% for i in (one..5) %}' +
+2 -2
View File
@@ -2,7 +2,7 @@ const Liquid = require('../..');
const mock = require('mock-fs');
const chai = require("chai");
const expect = chai.expect;
const error = require('../../src/error.js');
const ParseError = Liquid.Types.ParseError;
chai.use(require("chai-as-promised"));
describe('tags/include', function() {
@@ -52,7 +52,7 @@ describe('tags/include', function() {
it('should throw when illegal', function() {
return expect(liquid.renderFile('/illegal.html')).to.
be.rejectedWith(error.ParseError, /illegal token {%include%}/);
be.rejectedWith(ParseError, /illegal token {%include%}/);
});
it('should support include with relative path', function() {
-1
View File
@@ -2,7 +2,6 @@ const Liquid = require('../..');
const mock = require('mock-fs');
const chai = require("chai");
const expect = chai.expect;
const error = require('../../src/error.js');
chai.use(require("chai-as-promised"));
describe('tags/layout', function() {
-1
View File
@@ -1,7 +1,6 @@
const Liquid = require('../..');
const chai = require("chai");
const expect = chai.expect;
const error = require('../../src/error.js');
chai.use(require("chai-as-promised"));
describe('tags/tablerow', function() {
+4 -3
View File
@@ -1,8 +1,9 @@
var chai = require("chai");
var expect = chai.expect;
var engine = require('..')(), ctx;
const chai = require("chai");
const expect = chai.expect;
const mock = require('mock-fs');
var engine = require('../..')(), ctx;
function test(promise, cb){
return promise
.then((result) => {