mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Marko v3: Updated tests to work with concise mode
This commit is contained in:
parent
2ee712ba53
commit
fc824cdbf4
@ -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
|
||||
|
||||
2
test/fixtures/api-tests/global-data.marko
vendored
2
test/fixtures/api-tests/global-data.marko
vendored
@ -1 +1 @@
|
||||
${out.global.foo}
|
||||
- ${out.global.foo}
|
||||
2
test/fixtures/api-tests/hello-error.marko
vendored
2
test/fixtures/api-tests/hello-error.marko
vendored
@ -1 +1 @@
|
||||
{% throw new Error('Test'); %}
|
||||
<% throw new Error('Test'); %>
|
||||
2
test/fixtures/api-tests/hello-global.marko
vendored
2
test/fixtures/api-tests/hello-global.marko
vendored
@ -1 +1 @@
|
||||
${out.global.greeting} ${data.name}!
|
||||
- ${out.global.greeting} ${data.name}!
|
||||
|
||||
2
test/fixtures/api-tests/hello.marko
vendored
2
test/fixtures/api-tests/hello.marko
vendored
@ -1 +1 @@
|
||||
Hello ${data.name}!
|
||||
- Hello ${data.name}!
|
||||
2
test/fixtures/api-tests/write-to-disk.marko
vendored
2
test/fixtures/api-tests/write-to-disk.marko
vendored
@ -1 +1 @@
|
||||
Hello ${data.name}!
|
||||
- Hello ${data.name}!
|
||||
@ -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);
|
||||
});
|
||||
};
|
||||
}
|
||||
@ -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:'),
|
||||
@ -1,4 +1,6 @@
|
||||
---
|
||||
Hello John & Suzy
|
||||
Invalid Entity: &b ;
|
||||
Valid Numeric Entity: "
|
||||
Valid Hexadecimal Entity: ¢
|
||||
Valid Hexadecimal Entity: ¢
|
||||
---
|
||||
@ -1 +1 @@
|
||||
Hello ${data.name}! Hello $!{data.name}! Hello $!{data.missing}!
|
||||
- Hello ${data.name}! Hello $!{data.name}! Hello $!{data.missing}!
|
||||
@ -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>
|
||||
---
|
||||
@ -1 +1 @@
|
||||
Hello John
|
||||
- Hello John
|
||||
@ -1,5 +1,7 @@
|
||||
---
|
||||
<template-init>
|
||||
var name = '${name}<div if(foo)></div>';
|
||||
</template-init>
|
||||
|
||||
Hello ${name}!
|
||||
Hello ${name}!
|
||||
---
|
||||
Loading…
x
Reference in New Issue
Block a user