Marko v3: Updated tests to work with concise mode

This commit is contained in:
Patrick Steele-Idem 2016-02-02 16:02:46 -07:00
parent 2ee712ba53
commit fc824cdbf4
13 changed files with 31 additions and 27 deletions

View File

@ -21,9 +21,8 @@ describe('api' , function() {
});
it('should allow a template to be rendered using a callback', function(done) {
marko.render(
nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'),
{
var template = marko.load(nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'));
template.render({
name: 'John'
},
function(err, output) {
@ -47,9 +46,8 @@ describe('api' , function() {
done(e);
});
marko.render(
nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'),
{
var template = marko.load(nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'));
template.render({
name: 'John'
},
out);
@ -74,9 +72,9 @@ describe('api' , function() {
done(e);
});
marko.render(
nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'),
{
var template = marko.load(nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'));
template.render({
name: 'John'
},
out).end();
@ -94,8 +92,8 @@ describe('api' , function() {
});
marko.stream(
nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'),
var template = require(nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'));
template.stream(
{
name: 'John'
})
@ -400,12 +398,12 @@ describe('api' , function() {
// Make sure calling load with templatePath:String, templateSrc:String arguments works
templatePath = nodePath.join(__dirname, 'dummy.marko');
template = marko.load(templatePath, 'Hello $!{data.name}!');
template = marko.load(templatePath, '- Hello $!{data.name}!');
expect(template.renderSync({name: 'Frank'})).to.equal('Hello Frank!');
// Make sure calling load with templatePath:String, templateSrc:String, options:Object arguments works
templatePath = nodePath.join(__dirname, 'dummy.marko');
template = marko.load(templatePath, 'Hello $!{data.name}!', {});
template = marko.load(templatePath, '- Hello $!{data.name}!', {});
expect(template.renderSync({name: 'Frank'})).to.equal('Hello Frank!');
// Make sure calling load with templatePath:String, options:Object arguments works

View File

@ -1 +1 @@
${out.global.foo}
- ${out.global.foo}

View File

@ -1 +1 @@
{% throw new Error('Test'); %}
<% throw new Error('Test'); %>

View File

@ -1 +1 @@
${out.global.greeting} ${data.name}!
- ${out.global.greeting} ${data.name}!

View File

@ -1 +1 @@
Hello ${data.name}!
- Hello ${data.name}!

View File

@ -1 +1 @@
Hello ${data.name}!
- Hello ${data.name}!

View File

@ -3,11 +3,11 @@ function create(__helpers) {
empty = __helpers.e,
notEmpty = __helpers.ne,
escapeXml = __helpers.x,
forEach = __helpers.f;
forEachProp = __helpers.fp;
return function render(data, out) {
forEach(data.colors, function(color) {
out.w(escapeXml(color));
forEachProp(myObject, function(k, v) {
console.log("k:", k, "v:", v);
});
};
}

View File

@ -7,7 +7,7 @@ module.exports = function(builder) {
builder.forEachProp({
nameVarName: 'k',
valueVarName: 'v',
in: 'myArray',
in: 'myObject',
body: [
builder.functionCall('console.log', [
builder.literal('k:'),

View File

@ -1,4 +1,6 @@
---
Hello John &amp; Suzy
Invalid Entity: &b ;
Valid Numeric Entity: &#34;
Valid Hexadecimal Entity: &#x00A2;
Valid Hexadecimal Entity: &#x00A2;
---

View File

@ -1 +1 @@
Hello ${data.name}! Hello $!{data.name}! Hello $!{data.missing}!
- Hello ${data.name}! Hello $!{data.name}! Hello $!{data.missing}!

View File

@ -1,3 +1,4 @@
---
Hello ${data.name}!
<ul if(notEmpty(data.colors))>
@ -22,4 +23,5 @@ Hello ${data.name}!
<div>
No colors!
</div>
</else>
</else>
---

View File

@ -1 +1 @@
Hello John
- Hello John

View File

@ -1,5 +1,7 @@
---
<template-init>
var name = '${name}<div if(foo)></div>';
</template-init>
Hello ${name}!
Hello ${name}!
---