From dd0b420a7a1dbf01ad21a6ac65142d01fc95fdb5 Mon Sep 17 00:00:00 2001 From: Patrick Steele-Idem Date: Thu, 6 Feb 2014 21:13:51 -0700 Subject: [PATCH] Added test case for custom iterators --- test/render-rhtml-tests.js | 12 ++++++++++++ .../looping-iterator.rhtml.expected.html | 1 + 2 files changed, 13 insertions(+) create mode 100644 test/test-project/rhtml-templates/looping-iterator.rhtml.expected.html diff --git a/test/render-rhtml-tests.js b/test/render-rhtml-tests.js index 80c784f19..be1341f0b 100644 --- a/test/render-rhtml-tests.js +++ b/test/render-rhtml-tests.js @@ -369,5 +369,17 @@ describe('raptor-templates/rhtml' , function() { testRender("test-project/rhtml-templates/layout-use.rhtml", {}, done); }); + it("should work with custom iteration", function(done) { + testRender("test-project/rhtml-templates/looping-iterator.rhtml", { + reverseIterator: function(arrayList, callback){ + var statusVar = {first: 0, last: arrayList.length-1}; + for(var i=arrayList.length-1; i>=0; i--){ + statusVar.index = i; + callback(arrayList[i], statusVar); + } + } + }, done); + }); + }); diff --git a/test/test-project/rhtml-templates/looping-iterator.rhtml.expected.html b/test/test-project/rhtml-templates/looping-iterator.rhtml.expected.html new file mode 100644 index 000000000..ed6cd2adb --- /dev/null +++ b/test/test-project/rhtml-templates/looping-iterator.rhtml.expected.html @@ -0,0 +1 @@ +cba2-c1-b0-a
c
b
a
2-c
1-b
0-a
\ No newline at end of file