Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Add test case for issue erik168#17.
Browse files Browse the repository at this point in the history
  • Loading branch information
mytharcher committed Sep 3, 2012
1 parent 919e871 commit c5c8d9d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ test("merge", function() {
er.template.merge( el, 'mergeTest6_3' );
equals(el.innerHTML, '1,0|2,1|3,2|4,3|5,4', 'merge,for遍历数组,带数组索引');

er.template.parse('<!-- target:mergeTest6_4 --><!-- for: ${myObject.myList} as ${item} -->${item}<!-- /for -->');
er.context.set( 'myObject', {myList: [1,2,3,4,5]} );
er.template.merge( el, 'mergeTest6_4' );
equals(el.innerHTML, '12345', 'for遍历多级对象数组');

er.template.parse('<!-- target:mergeTest7 --><!-- if: ${num} > 0 -->${num}<!--elif: ${num} == 0-->zero<!--else-->invalid<!-- /if -->');
er.context.set( 'num', 1 );
er.template.merge( el, 'mergeTest7' );
Expand All @@ -132,6 +127,11 @@ test("merge", function() {
er.context.set( 'num', -1 );
er.template.merge( el, 'mergeTest7' );
equals(el.innerHTML, 'invalid', 'merge,进入else分支');

er.template.parse('<!-- target:mergeTest7_2 --><!-- if: ${num} == -1 -->${num}<!-- /if -->');
er.context.set( 'num', -1 );
er.template.merge( el, 'mergeTest7_2' );
equals(el.innerHTML, '-1', '负数也可以比较');

er.template.parse('<!-- target:mergeTest8 --><!-- if: ${num} || 1 -->1<!--/if-->');
er.context.set( 'num', 0 );
Expand Down

0 comments on commit c5c8d9d

Please sign in to comment.