Przeglądaj źródła

adjust tests to match new parser. adjust (most) tests for whitespace issues

tags/0.5.0-vsc
unknown 16 lat temu
rodzic
commit
82609d5c92
1 zmienionych plików z 24 dodań i 21 usunięć
  1. +24
    -21
      test/unit.js

+ 24
- 21
test/unit.js Wyświetl plik

@@ -25,7 +25,7 @@ test("Parser", function() {
},
{partial:'Hello {{ name}}\nYou have just won ${{value }}!\n{{# in_ca }}\nWell, ${{ taxed_value }}, after taxes.\n{{/ in_ca }}\n'}
),
'<h1>Welcome</h1>\nHello Chris\nYou have just won $10000!\nWell, $6000, after taxes.\n\n<h3>Fair enough, right?</h3>',
'<h1>Welcome</h1>\nHello Chris\nYou have just won $10000!\n\nWell, $6000, after taxes.\n\n\n<h3>Fair enough, right?</h3>',
'Whitespace in Tag names'
);
@@ -39,15 +39,18 @@ test("Parser", function() {
'Preservation of white space'
);
equals(
try {
Mustache.to_html(
'{{=tag1}}',
{ tag1: 'Hello' },
{}
),
'{{=tag1}}',
'ignore equal sign'
);
);

ok(false);
} catch (e) {
equals(e.message, 'Unexpected end of document.');
}
});

test("Basic Variables", function() {
@@ -65,7 +68,7 @@ test("Basic Variables", function() {
},
{}
),
'<h1>Bear &gt; Shark</h1>\nBut not &quot;.\n',
'<h1>Bear &gt; Shark</h1>\nBut not &amp;quot;.\n',
'HTML Escaping'
);
@@ -146,7 +149,7 @@ test("'#' (Sections)", function() {
{ numbers: ['1', '2', '3', '4'] },
{ partial: '{{.}}' }
),
'Here is some stuff!\n1\n2\n3\n4\n',
'Here is some stuff!\n\n1\n\n2\n\n3\n\n4\n',
'Array of Partials (Implicit)'
);
@@ -157,7 +160,7 @@ test("'#' (Sections)", function() {
{ numbers: [{i: '1'}, {i: '2'}, {i: '3'}, {i: '4'}] },
{ partial: '{{i}}' }
),
'Here is some stuff!\n1\n2\n3\n4\n',
'Here is some stuff!\n\n1\n\n2\n\n3\n\n4\n',
'Array of Partials (Explicit)'
);
@@ -187,7 +190,7 @@ test("'#' (Sections)", function() {
},
{}
),
'<b>Hi Tater.</b> To tinker?'
'<b>Hi Tater.</b> To tinker?\n'
);
// matches recursion_with_same_names.html
@@ -204,7 +207,7 @@ test("'#' (Sections)", function() {
},
{}
),
'name\ndesc\n\n t1\n 0\n t2\n 1\n'
'name\ndesc\n\n\n t1\n 0\n\n t2\n 1\n\n'
);
// matches reuse_of_enumerables.html
@@ -219,7 +222,7 @@ test("'#' (Sections)", function() {
},
{}
),
' t1\n 0\n t2\n 1\n t1\n 0\n t2\n 1\n',
'\n t1\n 0\n t2\n 1\n\n t1\n 0\n t2\n 1\n\n',
'Lazy match of Section and Inverted Section'
);
@@ -236,7 +239,7 @@ test("'#' (Sections)", function() {
},
{}
),
' <h1>this is an object</h1>\n <p>one of its attributes is a list</p>\n <ul>\n <li>listitem1</li>\n <li>listitem2</li>\n </ul>\n',
'\n <h1>this is an object</h1>\n <p>one of its attributes is a list</p>\n <ul>\n <li>listitem1</li>\n <li>listitem2</li>\n </ul>\n',
'Lazy match of Section and Inverted Section'
);
});
@@ -253,7 +256,7 @@ test("'^' (Inverted Section)", function() {
},
{}
),
'No repos :('
'\nNo repos :(\n'
);
});

@@ -284,7 +287,7 @@ test("'>' (Partials)", function() {
},
{partial: 'Hello {{name}}\nYou have just won ${{value}}!\n{{#in_ca}}\nWell, ${{ taxed_value }}, after taxes.\n{{/in_ca}}\n'}
),
'<h1>Welcome</h1>\nHello Chris\nYou have just won $10000!\nWell, $6000, after taxes.\n\n<h3>Fair enough, right?</h3>'
'<h1>Welcome</h1>\nHello Chris\nYou have just won $10000!\n\nWell, $6000, after taxes.\n\n\n<h3>Fair enough, right?</h3>'
);
// matches array_partial.html
@@ -298,7 +301,7 @@ test("'>' (Partials)", function() {
},
{ partial: 'Here\'s a non-sense array of values\n{{#array}}\n {{.}}\n{{/array}}' }
),
'Here\'s a non-sense array of values\n 1\n 2\n 3\n 4\n'
'Here\'s a non-sense array of values\n\n 1\n\n 2\n\n 3\n\n 4\n'
);
// matches template_partial.html
@@ -335,7 +338,7 @@ test("'>' (Partials)", function() {
},
{partial:'{{name}}\n{{#children}}\n{{>partial}}\n{{/children}}'}
),
'1\n1.1\n1.1.1\n\n\n'
'1\n\n1.1\n\n1.1.1\n\n\n'
);
try {
@@ -346,7 +349,7 @@ test("'>' (Partials)", function() {
);
ok(false);
} catch(e) {
equals(e.message, "unknown_partial 'partial'");
equals(e.message, "Unknown partial 'partial'");
}
});

@@ -365,7 +368,7 @@ test("'=' (Set Delimiter)", function() {
},
{}
),
'*\nIt worked the first time.\n* And it worked the second time.\n* Then, surprisingly, it worked the third time.\n* Fourth time also fine!.',
'*\nIt worked the first time.\n* And it worked the second time.\n\n* Then, surprisingly, it worked the third time.\n\n* Fourth time also fine!.',
'Simple Set Delimiter'
);
});
@@ -473,7 +476,7 @@ test("Demo", function() {
},
{}
),
'Hello Chris\nYou have just won $10000!\nWell, $6000, after taxes.\n',
'Hello Chris\nYou have just won $10000!\n\nWell, $6000, after taxes.\n',
'A simple template'
);
@@ -559,7 +562,7 @@ test("Regression Suite", function() {
{ enumerate: [ { text: 'A' }, { text: 'B' } ] },
{ partial: '{{=[[ ]]=}}\n{{text}}\n[[={{ }}=]]' }
),
'{{text}}\n\n{{text}}\n\n',
'\n\n{{text}}\n\n\n\n{{text}}\n\n',
'Issue 44'
);


Ładowanie…
Anuluj
Zapisz