Skip to content

Commit

Permalink
add test cases for object index lookup - the second one annoyingly fa…
Browse files Browse the repository at this point in the history
…ils :(
  • Loading branch information
michael-brade committed Jan 3, 2016
1 parent 962a890 commit 5014e37
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/templates.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var model = {
, yep: true
, nope: false
, nada: null
, objectA: { 'A': 'first', 'B': 'second' }
, letters: ['A', 'B', 'C']
, emptyList: []
, matrix: [[0, 1], [1, 0]]
Expand Down Expand Up @@ -361,6 +362,27 @@ describe('View insertion', function() {
expect(view.get(context)).equal('<div><p><b>Hi</b></p></div>');
});

it('attributes can be used as object index if defined as alias', function() {
var views = new templates.Views();
context.meta.views = views;
views.register('body', '<view is="section" attr="{{_page.letters[0]}}"><b>Hi</b></view>');
views.register('section', '<div><view is="paragraph" attr="{{@attr}}"></view></div>');
views.register('paragraph', '<p>{{with @attr as #attr}}{{_page.objectA[#attr]}}{{/}}</p>');
var view = views.find('body');
expect(view.get(context)).equal('<div><p>first</p></div>');
});

// This test fails
it.skip('attributes can be used as object index', function() {
var views = new templates.Views();
context.meta.views = views;
views.register('body', '<view is="section" attr="{{_page.letters[0]}}"><b>Hi</b></view>');
views.register('section', '<div><view is="paragraph" attr="{{@attr}}"></view></div>');
views.register('paragraph', '<p>{{_page.objectA[@attr]}}</p>');
var view = views.find('body');
expect(view.get(context)).equal('<div><p>first</p></div>');
});

it('views can define custom child attribute tags', function() {
var views = new templates.Views();
context.meta.views = views;
Expand Down

0 comments on commit 5014e37

Please sign in to comment.