Explorar el Código

Update unit tests based on merge with janl's branch

tags/0.5.0-vsc
thegrandpoobah hace 15 años
padre
commit
df7405b184
Se han modificado 2 ficheros con 60 adiciones y 4 borrados
  1. +30
    -2
      test/unit.compiler.js
  2. +30
    -2
      test/unit.interpreter.js

+ 30
- 2
test/unit.compiler.js Ver fichero

@@ -83,7 +83,7 @@ test("Parser", function() {
});

test("Basic Variables", function() {
expect(3);
expect(4);
// matches escaped.html
equals(
@@ -100,6 +100,17 @@ test("Basic Variables", function() {
'<h1>Bear &gt; Shark</h1>\nBut not &amp;quot;.\n',
'HTML Escaping'
);
// matches apostrophe.html (except in this implementation, apostrophes are not escaped.
equals(
Mustache.to_html(
'{{apos}}{{control}}',
{ apos: '\'', control: 'X' },
{}
),
'\'X',
'Apostrophe escaping'
);
// matches null_string.html
equals(
@@ -169,7 +180,7 @@ test("'{' or '&' (Unescaped Variable)", function() {
});

test("'#' (Sections)", function() {
expect(7);
expect(8);
// matches array_of_partials_implicit_partial.html
equals(
@@ -271,6 +282,23 @@ test("'#' (Sections)", function() {
'\n <h1>this is an object</h1>\n <p>one of its attributes is a list</p>\n <ul>\n \n <li>listitem1</li>\n \n <li>listitem2</li>\n \n </ul>\n\n',
'Lazy match of Section and Inverted Section'
);
// matches nesting.html
equals(
Mustache.to_html(
'{{#foo}}\n {{#a}}\n {{b}}\n {{/a}}\n{{/foo}}',
{
foo: [
{a: {b: 1}},
{a: {b: 2}},
{a: {b: 3}}
]
},
{}
),
'\n \n 1\n \n\n \n 2\n \n\n \n 3\n \n',
'Context Nesting'
);
});

test("'^' (Inverted Section)", function() {


+ 30
- 2
test/unit.interpreter.js Ver fichero

@@ -65,7 +65,7 @@ test("Parser", function() {
});

test("Basic Variables", function() {
expect(3);
expect(4);
// matches escaped.html
equals(
@@ -83,6 +83,17 @@ test("Basic Variables", function() {
'HTML Escaping'
);
// matches apostrophe.html (except in this implementation, apostrophes are not escaped.
equals(
Mustache.to_html(
'{{apos}}{{control}}',
{ apos: '\'', control: 'X' },
{}
),
'\'X',
'Apostrophe escaping'
);
// matches null_string.html
equals(
Mustache.to_html(
@@ -151,7 +162,7 @@ test("'{' or '&' (Unescaped Variable)", function() {
});

test("'#' (Sections)", function() {
expect(7);
expect(8);
// matches array_of_partials_implicit_partial.html
equals(
@@ -253,6 +264,23 @@ test("'#' (Sections)", function() {
'\n <h1>this is an object</h1>\n <p>one of its attributes is a list</p>\n <ul>\n \n <li>listitem1</li>\n \n <li>listitem2</li>\n \n </ul>\n\n',
'Lazy match of Section and Inverted Section'
);
// matches nesting.html
equals(
Mustache.to_html(
'{{#foo}}\n {{#a}}\n {{b}}\n {{/a}}\n{{/foo}}',
{
foo: [
{a: {b: 1}},
{a: {b: 2}},
{a: {b: 3}}
]
},
{}
),
'\n \n 1\n \n\n \n 2\n \n\n \n 3\n \n',
'Context Nesting'
);
});

test("'^' (Inverted Section)", function() {


Cargando…
Cancelar
Guardar