summaryrefslogtreecommitdiffstats
path: root/spec/track-ids.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/track-ids.js')
-rw-r--r--spec/track-ids.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/track-ids.js b/spec/track-ids.js
index 938f98b..f337fbe 100644
--- a/spec/track-ids.js
+++ b/spec/track-ids.js
@@ -106,6 +106,27 @@ describe('track ids', function() {
equals(template(context, {helpers: helpers}), 'HELP ME MY BOSS 1');
});
+ it('should use block param paths', function() {
+ var template = CompilerContext.compile('{{#doIt as |is|}}{{wycats is.a slave.driver is}}{{/doIt}}', {trackIds: true});
+
+ var helpers = {
+ doIt: function(options) {
+ var blockParams = [this.is];
+ blockParams.path = ['zomg'];
+ return options.fn(this, {blockParams: blockParams});
+ },
+ wycats: function(passiveVoice, noun, blah, options) {
+ equal(options.ids[0], 'zomg.a');
+ equal(options.ids[1], 'slave.driver');
+ equal(options.ids[2], 'zomg');
+
+ return "HELP ME MY BOSS " + options.ids[0] + ':' + passiveVoice + ' ' + options.ids[1] + ':' + noun;
+ }
+ };
+
+ equals(template(context, {helpers: helpers}), 'HELP ME MY BOSS zomg.a:foo slave.driver:bar');
+ });
+
describe('builtin helpers', function() {
var helpers = {
wycats: function(name, options) {
@@ -129,6 +150,17 @@ describe('track ids', function() {
equals(template({array: [{name: 'foo'}, {name: 'bar'}]}, {helpers: helpers}), 'foo:.array..0\nbar:.array..1\n');
});
+ it('should handle block params', function() {
+ var helpers = {
+ wycats: function(name, options) {
+ return name + ':' + options.ids[0] + '\n';
+ }
+ };
+
+ var template = CompilerContext.compile('{{#each array as |value|}}{{wycats value.name}}{{/each}}', {trackIds: true});
+
+ equals(template({array: [{name: 'foo'}, {name: 'bar'}]}, {helpers: helpers}), 'foo:array.0.name\nbar:array.1.name\n');
+ });
});
describe('#with', function() {
it('should track contextPath', function() {