mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Reorganized and cleaned up test files
This commit is contained in:
parent
edd6d60fe5
commit
6f7567d0b0
@ -12,7 +12,8 @@
|
||||
"url": "https://github.com/raptorjs/marko.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/"
|
||||
"test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/",
|
||||
"test-fast": "node_modules/.bin/mocha --ui bdd --reporter spec ./test/render-test"
|
||||
},
|
||||
"author": "Patrick Steele-Idem <pnidem@gmail.com>",
|
||||
"maintainers": [
|
||||
|
||||
@ -20,7 +20,7 @@ describe('marko/api' , function() {
|
||||
|
||||
it('should allow a template to be rendered using a callback', function(done) {
|
||||
marko.render(
|
||||
nodePath.join(__dirname, 'test-project/hello.marko'),
|
||||
nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
|
||||
{
|
||||
name: 'John'
|
||||
},
|
||||
@ -46,7 +46,7 @@ describe('marko/api' , function() {
|
||||
});
|
||||
|
||||
marko.render(
|
||||
nodePath.join(__dirname, 'test-project/hello.marko'),
|
||||
nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
|
||||
{
|
||||
name: 'John'
|
||||
},
|
||||
@ -73,7 +73,7 @@ describe('marko/api' , function() {
|
||||
});
|
||||
|
||||
marko.render(
|
||||
nodePath.join(__dirname, 'test-project/hello.marko'),
|
||||
nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
|
||||
{
|
||||
name: 'John'
|
||||
},
|
||||
@ -93,7 +93,7 @@ describe('marko/api' , function() {
|
||||
|
||||
|
||||
marko.stream(
|
||||
nodePath.join(__dirname, 'test-project/hello.marko'),
|
||||
nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
|
||||
{
|
||||
name: 'John'
|
||||
})
|
||||
@ -107,7 +107,7 @@ describe('marko/api' , function() {
|
||||
/// TEMPLATE LOADING:
|
||||
|
||||
it('should allow a template to be loaded and rendered using a callback', function(done) {
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'));
|
||||
template.render({
|
||||
name: 'John'
|
||||
},
|
||||
@ -132,7 +132,7 @@ describe('marko/api' , function() {
|
||||
done(e);
|
||||
});
|
||||
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'));
|
||||
template.render({
|
||||
name: 'John'
|
||||
},
|
||||
@ -158,7 +158,7 @@ describe('marko/api' , function() {
|
||||
done(e);
|
||||
});
|
||||
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'));
|
||||
template.render({
|
||||
name: 'John'
|
||||
},
|
||||
@ -166,7 +166,7 @@ describe('marko/api' , function() {
|
||||
});
|
||||
|
||||
it('should allow a template to be loaded and rendered to a stream', function(done) {
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'));
|
||||
|
||||
var output = '';
|
||||
var outStream = through(function write(data) {
|
||||
@ -189,13 +189,13 @@ describe('marko/api' , function() {
|
||||
});
|
||||
|
||||
it('should allow a template to be rendered to a string synchronously using renderSync', function() {
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'));
|
||||
var output = template.renderSync({ name: 'John' });
|
||||
expect(output).to.equal('Hello John!');
|
||||
});
|
||||
|
||||
it('should allow a template to be rendered synchronously using global attributes', function() {
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello-global.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello-global.marko'));
|
||||
var data = {
|
||||
name: 'John',
|
||||
$global: {
|
||||
@ -207,7 +207,7 @@ describe('marko/api' , function() {
|
||||
});
|
||||
|
||||
it('should allow a template to be rendered asynchronously using global attributes', function(done) {
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello-global.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello-global.marko'));
|
||||
var data = {
|
||||
name: 'John',
|
||||
$global: {
|
||||
@ -221,7 +221,7 @@ describe('marko/api' , function() {
|
||||
});
|
||||
|
||||
it('should throw an error if beginAsync is used with renderSync', function() {
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello-async.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello-async.marko'));
|
||||
var output;
|
||||
var e;
|
||||
|
||||
@ -242,7 +242,7 @@ describe('marko/api' , function() {
|
||||
});
|
||||
|
||||
it('should throw errors correctly with renderSync', function() {
|
||||
var template = marko.load(nodePath.join(__dirname, 'test-project/hello-error.marko'));
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/templates/api-tests/hello-error.marko'));
|
||||
var output;
|
||||
var e;
|
||||
|
||||
|
||||
@ -2,19 +2,17 @@
|
||||
var chai = require('chai');
|
||||
chai.Assertion.includeStack = true;
|
||||
require('chai').should();
|
||||
var expect = require('chai').expect;
|
||||
var nodePath = require('path');
|
||||
var fs = require('fs');
|
||||
var logger = require('raptor-logging').logger(module);
|
||||
|
||||
function testCompiler(path) {
|
||||
var inputPath = nodePath.join(__dirname, path);
|
||||
var expectedPath = nodePath.join(__dirname, path + '.expected.js');
|
||||
var actualPath = nodePath.join(__dirname, path + '.actual.js');
|
||||
var templatePath = nodePath.join(__dirname, path, 'template.marko');
|
||||
var expectedPath = nodePath.join(__dirname, path, 'expected.js');
|
||||
var actualPath = nodePath.join(__dirname, path, 'template.marko.js');
|
||||
|
||||
var compiler = require('../compiler').createCompiler(templatePath);
|
||||
var src = fs.readFileSync(templatePath, {encoding: 'utf8'});
|
||||
|
||||
var compiler = require('../compiler').createCompiler(inputPath);
|
||||
var src = fs.readFileSync(inputPath, {encoding: 'utf8'});
|
||||
|
||||
var output = compiler.compile(src);
|
||||
fs.writeFileSync(actualPath, output, {encoding: 'utf8'});
|
||||
|
||||
@ -28,7 +26,7 @@ function testCompiler(path) {
|
||||
}
|
||||
|
||||
if (output !== expected) {
|
||||
throw new Error('Unexpected output for "' + inputPath + '":\nEXPECTED (' + expectedPath + '):\n---------\n' + expected +
|
||||
throw new Error('Unexpected output for "' + templatePath + '":\nEXPECTED (' + expectedPath + '):\n---------\n' + expected +
|
||||
'\n---------\nACTUAL (' + actualPath + '):\n---------\n' + output + '\n---------');
|
||||
}
|
||||
}
|
||||
@ -50,15 +48,15 @@ describe('marko/compiler' , function() {
|
||||
});
|
||||
|
||||
it('should compile a simple template', function() {
|
||||
testCompiler('test-project/simple.marko');
|
||||
testCompiler('fixtures/templates/compiler/simple');
|
||||
});
|
||||
|
||||
it('should compile a simple template with custom tag', function() {
|
||||
testCompiler('test-project/custom-tag.marko');
|
||||
testCompiler('fixtures/templates/compiler/custom-tag');
|
||||
});
|
||||
|
||||
it('should compile a simple template with expressions', function() {
|
||||
testCompiler('test-project/hello-dynamic.marko');
|
||||
testCompiler('fixtures/templates/compiler/hello-dynamic');
|
||||
});
|
||||
|
||||
// it.only('should compile a template with <c:invoke>', function() {
|
||||
@ -69,6 +67,6 @@ describe('marko/compiler' , function() {
|
||||
// testCompiler('test-project/test-templates/include.marko');
|
||||
// });
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ describe('marko/dust' , function() {
|
||||
}
|
||||
};
|
||||
|
||||
testRender('test-project/dust/async.dust', {
|
||||
testRender('fixtures/dust/async.dust', {
|
||||
userIds: [0, 1, 2, 3],
|
||||
userInfo: function(arg, callback) {
|
||||
callback(null, users[arg.userId]);
|
||||
|
||||
@ -5,20 +5,20 @@
|
||||
"global-attribute": "boolean"
|
||||
}
|
||||
},
|
||||
"test-hello": "hello-tag.json",
|
||||
"test-hello": "taglib/hello-tag.json",
|
||||
"test-simpleHello": {
|
||||
"renderer": "./simple-hello-tag.js",
|
||||
"renderer": "./taglib/simple-hello-tag.js",
|
||||
"attributes": {
|
||||
"name": "string",
|
||||
"adult": "boolean"
|
||||
}
|
||||
},
|
||||
"test-tabs": {
|
||||
"renderer": "./tabs-tag.js",
|
||||
"renderer": "./taglib/tabs-tag.js",
|
||||
"var": "tabs"
|
||||
},
|
||||
"test-tab": {
|
||||
"renderer": "./tab-tag.js",
|
||||
"renderer": "./taglib/tab-tag.js",
|
||||
"import-var": {
|
||||
"tabs": "tabs"
|
||||
},
|
||||
@ -27,11 +27,11 @@
|
||||
}
|
||||
},
|
||||
"test-tabs-new": {
|
||||
"renderer": "./tabs-new-tag.js",
|
||||
"renderer": "./taglib/tabs-new-tag.js",
|
||||
"body-function": "buildTabs(__tabsHelper)"
|
||||
},
|
||||
"test-tab-new": {
|
||||
"renderer": "./tab-new-tag.js",
|
||||
"renderer": "./taglib/tab-new-tag.js",
|
||||
"import-var": {
|
||||
"tabs": "__tabsHelper"
|
||||
},
|
||||
@ -40,7 +40,7 @@
|
||||
}
|
||||
},
|
||||
"test-dynamic-attributes": {
|
||||
"renderer": "./dynamic-attributes-tag.js",
|
||||
"renderer": "./taglib/dynamic-attributes-tag.js",
|
||||
"attributes": {
|
||||
"test": "string",
|
||||
"*": {
|
||||
@ -50,14 +50,14 @@
|
||||
}
|
||||
},
|
||||
"test-dynamic-attributes2": {
|
||||
"renderer": "./dynamic-attributes-tag2.js",
|
||||
"renderer": "./taglib/dynamic-attributes-tag2.js",
|
||||
"attributes": {
|
||||
"test": "string",
|
||||
"*": "string"
|
||||
}
|
||||
},
|
||||
"test-dynamic-attributes3": {
|
||||
"renderer": "./dynamic-attributes-tag3.js",
|
||||
"renderer": "./taglib/dynamic-attributes-tag3.js",
|
||||
"attributes": {
|
||||
"test": "string",
|
||||
"*": {
|
||||
@ -67,20 +67,20 @@
|
||||
}
|
||||
},
|
||||
"test-popover": {
|
||||
"renderer": "./popover-tag.js",
|
||||
"renderer": "./taglib/popover-tag.js",
|
||||
"attributes": {
|
||||
"title": "string",
|
||||
"content": "string"
|
||||
}
|
||||
},
|
||||
"test-page-title": {
|
||||
"template": "./page-title-tag.marko",
|
||||
"template": "./taglib/page-title-tag.marko",
|
||||
"attributes": {
|
||||
"title": "string"
|
||||
}
|
||||
},
|
||||
"test-default-attributes": {
|
||||
"renderer": "./default-attributes-tag.js",
|
||||
"renderer": "./taglib/default-attributes-tag.js",
|
||||
"attributes": {
|
||||
"prop1": "string",
|
||||
"prop2": "integer",
|
||||
@ -95,9 +95,9 @@
|
||||
}
|
||||
},
|
||||
"test-template-tag-dynamic-attributes": {
|
||||
"template": "./hello.marko"
|
||||
"template": "./taglib/hello.marko"
|
||||
}
|
||||
},
|
||||
"tags-dir": "./scanned-tags",
|
||||
"tags-dir": "./taglib/scanned-tags",
|
||||
"taglib-imports": ["./package.json"]
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
var marko = require('../../');
|
||||
var marko = require('../../../');
|
||||
|
||||
exports.render = function(input, out) {
|
||||
marko.render(require.resolve('./popover.marko'), {
|
||||
@ -1,4 +1,4 @@
|
||||
var marko = require('../../');
|
||||
var marko = require('../../../');
|
||||
|
||||
exports.render = function(input, out) {
|
||||
var tabs = [],
|
||||
@ -1,31 +1,31 @@
|
||||
var marko = require('../../');
|
||||
var marko = require('../../../');
|
||||
|
||||
exports.render = function(input, out) {
|
||||
var tabs = [],
|
||||
var tabs = [],
|
||||
activeFound = false;
|
||||
|
||||
|
||||
input.invokeBody({
|
||||
addTab: function(tab) {
|
||||
if (tab.active) {
|
||||
tab.activeFound = true;
|
||||
}
|
||||
|
||||
|
||||
tab.id = "tab" + tabs.length;
|
||||
tabs.push(tab);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!activeFound && tabs.length) {
|
||||
tabs[0].active = true;
|
||||
}
|
||||
|
||||
|
||||
tabs.forEach(function(tab) {
|
||||
tab.liClass = tab.active ? "active" : "";
|
||||
tab.divClass = tab.active ? "tab-pane active" : "tab-pane";
|
||||
});
|
||||
|
||||
|
||||
marko.render(require.resolve('./tabs.marko'), {
|
||||
tabs: tabs
|
||||
}, out);
|
||||
|
||||
|
||||
};
|
||||
1
test/fixtures/templates/api-tests/hello.marko
vendored
Normal file
1
test/fixtures/templates/api-tests/hello.marko
vendored
Normal file
@ -0,0 +1 @@
|
||||
Hello $data.name!
|
||||
1
test/fixtures/templates/async-fragment-args/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-args/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<ul><li><ul><li><b>Name:</b> John B. Flowers</li><li><b>Gender:</b> Male</li><li><b>Occupation:</b> Clock repairer</li></ul></li><li><ul><li><b>Name:</b> Pamela R. Rice</li><li><b>Gender:</b> Female</li><li><b>Occupation:</b> Cartographer</li></ul></li><li><ul><li><b>Name:</b> Barbara C. Rigsby</li><li><b>Gender:</b> Female</li><li><b>Occupation:</b> Enrollment specialist</li></ul></li><li><ul><li><b>Name:</b> Anthony J. Ward</li><li><b>Gender:</b> Male</li><li><b>Occupation:</b> Clinical laboratory technologist</li></ul></li></ul>
|
||||
1
test/fixtures/templates/async-fragment-client-reorder/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-client-reorder/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<span id="afph0"></span><script type="text/javascript">function $af(d,a,e,l,g,h,k,b,f,c){c=$af;if(a&&!c[a])(c[a+="$"]||(c[a]=[])).push(d);else{e=document;l=e.getElementById("af"+d);g=e.getElementById("afph"+d);h=e.createDocumentFragment();k=l.childNodes;b=0;for(f=k.length;b<f;b++)h.appendChild(k.item(0));g.parentNode.replaceChild(h,g);c[d]=1;if(a=c[d+"$"])for(b=0,f=a.length;b<f;b++)c(a[b])}};</script><div id="af0" style="display:none"><h1>Outer</h1><span id="afph1"></span><span id="afph2"></span></div><script type="text/javascript">$af(0)</script><div id="af1" style="display:none"><h2>Inner 1</h2></div><script type="text/javascript">$af(1)</script><div id="af2" style="display:none"><h2>Inner 2</h2></div><script type="text/javascript">$af(2)</script>
|
||||
1
test/fixtures/templates/async-fragment-data-providers/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-data-providers/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
testContextDatatestSharedData
|
||||
1
test/fixtures/templates/async-fragment-error/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-error/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
1-An error has occurred!2-An error has occurred!
|
||||
1
test/fixtures/templates/async-fragment-macros/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-macros/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
1 2 3
|
||||
1
test/fixtures/templates/async-fragment-ordering/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-ordering/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
1 2 3 4 5 6 7 8 9
|
||||
1
test/fixtures/templates/async-fragment-ordering2/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-ordering2/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
||||
1
test/fixtures/templates/async-fragment-promise/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-promise/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
Test promise
|
||||
1
test/fixtures/templates/async-fragment-timeout-message/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-timeout-message/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
Server is busy!
|
||||
1
test/fixtures/templates/async-fragment-timeout/expected.html
vendored
Normal file
1
test/fixtures/templates/async-fragment-timeout/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
1-A timeout has occurred!2-A timeout has occurred!
|
||||
1
test/fixtures/templates/body-only-if/expected.html
vendored
Normal file
1
test/fixtures/templates/body-only-if/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<a href="/foo">Some Link</a>Another Link
|
||||
1
test/fixtures/templates/boolean-attributes/expected.html
vendored
Normal file
1
test/fixtures/templates/boolean-attributes/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<input type="checkbox" checked><button disabled>Button</button><select><option value="red">red</option><option value="green" selected>green</option><option value="blue">blue</option></select>
|
||||
1
test/fixtures/templates/c-input-plus-attrs/expected.html
vendored
Normal file
1
test/fixtures/templates/c-input-plus-attrs/expected.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
Hello Frank! adult=trueHello Jane! adult=true
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user