diff --git a/packages/spacebars-tests/template_tests.html b/packages/spacebars-tests/template_tests.html
index 299d937556..b77737b20e 100644
--- a/packages/spacebars-tests/template_tests.html
+++ b/packages/spacebars-tests/template_tests.html
@@ -1089,3 +1089,9 @@ Hi there!
{{/with}}
+
+ {{#each things}}
+ {{@index}} - {{num}}
+ {{/each}}
+
+
diff --git a/packages/spacebars-tests/template_tests.js b/packages/spacebars-tests/template_tests.js
index 415e817b5e..4df79da951 100644
--- a/packages/spacebars-tests/template_tests.js
+++ b/packages/spacebars-tests/template_tests.js
@@ -3292,3 +3292,39 @@ Tinytest.add("spacebars-tests - template_tests - let bindings", function (test)
Blaze.remove(view);
});
+Tinytest.add("spacebars-tests - template_tests - #each @index", function (test) {
+ var tmpl = Template.spacebars_template_test_each_index;
+
+ var c = new Mongo.Collection();
+ c.insert({ num: 2 });
+ c.insert({ num: 4 });
+ tmpl.helpers({
+ things: function () {
+ return c.find({}, {sort:{num: 1}});
+ }
+ });
+
+ var div = document.createElement("DIV");
+ var theEach = Blaze.render(tmpl, div);
+ test.equal(canonicalizeHtml(div.innerHTML), '0 - 21 - 4');
+
+ c.insert({ num: 1 });
+ Tracker.flush();
+ test.equal(canonicalizeHtml(div.innerHTML), '0 - 11 - 22 - 4');
+
+ var three = c.insert({ num: 3 });
+ Tracker.flush();
+ test.equal(canonicalizeHtml(div.innerHTML), '0 - 11 - 22 - 33 - 4');
+
+ c.update(three, { num: 0 });
+ Tracker.flush();
+ test.equal(canonicalizeHtml(div.innerHTML), '0 - 01 - 12 - 23 - 4');
+
+ c.remove(three);
+ Tracker.flush();
+ test.equal(canonicalizeHtml(div.innerHTML), '0 - 11 - 22 - 4');
+
+ var view = Blaze.getView(div.querySelector('span'));
+ Blaze.remove(view);
+});
+