diff --git a/src/util/underscore.ts b/src/util/underscore.ts index e0e2c40e5..9a32239fc 100644 --- a/src/util/underscore.ts +++ b/src/util/underscore.ts @@ -32,6 +32,7 @@ export function stringify (value: any): string { value = toValue(value) if (isString(value)) return value if (isNil(value)) return '' + if (isArray(value)) return value.map(x => stringify(x)).join('') return String(value) } diff --git a/test/e2e/issues.ts b/test/e2e/issues.ts index 93ad7b4e0..4236e43a4 100644 --- a/test/e2e/issues.ts +++ b/test/e2e/issues.ts @@ -103,7 +103,7 @@ describe('Issues', function () { const html = await engine.parseAndRender( `{{ 'a \n b \n c' | newline_to_br | split: '
' }}` ) - expect(html).to.equal('a ,\n b ,\n c') + expect(html).to.equal('a \n b \n c') }) it('#342 New lines in logical operator', async () => { const engine = new Liquid() diff --git a/test/e2e/parse-and-render.ts b/test/e2e/parse-and-render.ts index 6a0ba9114..c86bd79a2 100644 --- a/test/e2e/parse-and-render.ts +++ b/test/e2e/parse-and-render.ts @@ -15,7 +15,7 @@ describe('.parseAndRender()', function () { it('should stringify array ', async function () { var ctx = { arr: [-2, 'a'] } const html = await engine.parseAndRender('{{arr}}', ctx) - return expect(html).to.equal('-2,a') + return expect(html).to.equal('-2a') }) it('should render undefined as empty', async function () { const html = await engine.parseAndRender('foo{{zzz}}bar', {}) @@ -41,9 +41,9 @@ describe('.parseAndRender()', function () { const ctx = { obj: [1, 2] } const template = engine.parse('{{obj}}') const result = await engine.render(template, ctx) - expect(result).to.equal('1,2') + expect(result).to.equal('12') const result2 = await engine.render(template, ctx) - expect(result2).to.equal('1,2') + expect(result2).to.equal('12') }) it('should support the "join" filter', async function () { var ctx = { names: ['alice', 'bob'] } diff --git a/test/integration/builtin/filters/array.ts b/test/integration/builtin/filters/array.ts index 3561eb329..f28941dcd 100644 --- a/test/integration/builtin/filters/array.ts +++ b/test/integration/builtin/filters/array.ts @@ -36,7 +36,7 @@ describe('filters/array', function () { describe('map', () => { it('should support map', function () { const posts = [{ category: 'foo' }, { category: 'bar' }] - return test('{{posts | map: "category"}}', { posts }, 'foo,bar') + return test('{{posts | map: "category"}}', { posts }, 'foobar') }) it('should normalize non-array input', function () { const post = { category: 'foo' } @@ -53,7 +53,7 @@ describe('filters/array', function () { describe('compact', () => { it('should compact array', function () { const posts = [{ category: 'foo' }, { category: 'bar' }, { foo: 'bar' }] - return test('{{posts | map: "category" | compact}}', { posts }, 'foo,bar') + return test('{{posts | map: "category" | compact}}', { posts }, 'foobar') }) }) describe('reverse', function () { diff --git a/test/integration/builtin/tags/assign.ts b/test/integration/builtin/tags/assign.ts index dcf34e919..f27c60a2b 100644 --- a/test/integration/builtin/tags/assign.ts +++ b/test/integration/builtin/tags/assign.ts @@ -24,7 +24,7 @@ describe('tags/assign', function () { it('should assign as array', async function () { const src = '{% assign foo=(1..3) %}{{foo}}' const html = await liquid.parseAndRender(src) - return expect(html).to.equal('1,2,3') + return expect(html).to.equal('123') }) it('should assign as filter result', async function () { const src = '{% assign foo="a b" | capitalize | split: " " | first %}{{foo}}'