Skip to content

Commit

Permalink
Also supply a test with keys for map filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineveldhoven committed Sep 27, 2023
1 parent bdcd4ce commit 5a7d299
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/test.filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,11 @@ describe('Twig.js Filters ->', function () {

describe('map ->', function () {
it('should map an array (with keys)', function () {
let testTemplate = twig({data: '{{ [1,5,2,7,8]|map((v, k) => v*v+k) }}'});
testTemplate.render().should.equal('1,26,6,52,68');
});

it('should map an array', function () {
let testTemplate = twig({data: '{{ [1,5,2,7,8]|map((v) => v*v) }}'});
testTemplate.render().should.equal('1,25,4,49,64');
});
Expand Down

0 comments on commit 5a7d299

Please sign in to comment.