Skip to content

Commit

Permalink
Merge pull request #161 from bc-williamkwon/refactorFor
Browse files Browse the repository at this point in the history
STRF-6836 For helper should iterate once
  • Loading branch information
mattolson authored Jun 12, 2019
2 parents 1c8ba10 + 66be004 commit e2cea8d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Unreleased
-- Fix for helper to allow for one iteration

## 2.0.13 (2019-05-24)
-- Change default behavior of {{getFontsCollection}} to use font-display: swap for Google Fonts and allow configuration

Expand Down
2 changes: 1 addition & 1 deletion helpers/for.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function helper(paper) {
}
}

if (to <= from) {
if (to < from) {
return;
}

Expand Down
16 changes: 16 additions & 0 deletions test/helpers/for.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@ function c(template, context) {
describe('for helper', function() {

var context = {name: 'Joe'};

it('should iterate once', function(done) {

expect(c('{{#for 1 this}}{{$index}}:{{name}} {{/for}}', context))
.to.contain('1:Joe');

expect(c('{{#for 1 1 this}}{{$index}}:{{name}} {{/for}}', context))
.to.contain('1:Joe');

expect(c('{{#for 0 0 this}}{{$index}}:{{name}} {{/for}}', context))
.to.contain('0:Joe');

expect(c('{{#for 1000 1000 this}}{{$index}}:{{name}} {{/for}}', context))
.to.contain('1000:Joe');

done();
})
it('should itarate 10 times', function(done) {

expect(c('{{#for 10 this}}{{$index}}:{{name}} {{/for}}', context))
Expand Down

0 comments on commit e2cea8d

Please sign in to comment.