Reorganized and cleaned up test files

This commit is contained in:
Patrick Steele-Idem 2015-04-10 18:24:39 -06:00
parent edd6d60fe5
commit 6f7567d0b0
434 changed files with 435 additions and 916 deletions

View File

@ -12,7 +12,8 @@
"url": "https://github.com/raptorjs/marko.git" "url": "https://github.com/raptorjs/marko.git"
}, },
"scripts": { "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>", "author": "Patrick Steele-Idem <pnidem@gmail.com>",
"maintainers": [ "maintainers": [

View File

@ -20,7 +20,7 @@ describe('marko/api' , function() {
it('should allow a template to be rendered using a callback', function(done) { it('should allow a template to be rendered using a callback', function(done) {
marko.render( marko.render(
nodePath.join(__dirname, 'test-project/hello.marko'), nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
{ {
name: 'John' name: 'John'
}, },
@ -46,7 +46,7 @@ describe('marko/api' , function() {
}); });
marko.render( marko.render(
nodePath.join(__dirname, 'test-project/hello.marko'), nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
{ {
name: 'John' name: 'John'
}, },
@ -73,7 +73,7 @@ describe('marko/api' , function() {
}); });
marko.render( marko.render(
nodePath.join(__dirname, 'test-project/hello.marko'), nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
{ {
name: 'John' name: 'John'
}, },
@ -93,7 +93,7 @@ describe('marko/api' , function() {
marko.stream( marko.stream(
nodePath.join(__dirname, 'test-project/hello.marko'), nodePath.join(__dirname, 'fixtures/templates/api-tests/hello.marko'),
{ {
name: 'John' name: 'John'
}) })
@ -107,7 +107,7 @@ describe('marko/api' , function() {
/// TEMPLATE LOADING: /// TEMPLATE LOADING:
it('should allow a template to be loaded and rendered using a callback', function(done) { 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({ template.render({
name: 'John' name: 'John'
}, },
@ -132,7 +132,7 @@ describe('marko/api' , function() {
done(e); 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({ template.render({
name: 'John' name: 'John'
}, },
@ -158,7 +158,7 @@ describe('marko/api' , function() {
done(e); 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({ template.render({
name: 'John' 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) { 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 output = '';
var outStream = through(function write(data) { 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() { 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' }); var output = template.renderSync({ name: 'John' });
expect(output).to.equal('Hello John!'); expect(output).to.equal('Hello John!');
}); });
it('should allow a template to be rendered synchronously using global attributes', function() { 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 = { var data = {
name: 'John', name: 'John',
$global: { $global: {
@ -207,7 +207,7 @@ describe('marko/api' , function() {
}); });
it('should allow a template to be rendered asynchronously using global attributes', function(done) { 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 = { var data = {
name: 'John', name: 'John',
$global: { $global: {
@ -221,7 +221,7 @@ describe('marko/api' , function() {
}); });
it('should throw an error if beginAsync is used with renderSync', 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 output;
var e; var e;
@ -242,7 +242,7 @@ describe('marko/api' , function() {
}); });
it('should throw errors correctly with renderSync', 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 output;
var e; var e;

View File

@ -2,19 +2,17 @@
var chai = require('chai'); var chai = require('chai');
chai.Assertion.includeStack = true; chai.Assertion.includeStack = true;
require('chai').should(); require('chai').should();
var expect = require('chai').expect;
var nodePath = require('path'); var nodePath = require('path');
var fs = require('fs'); var fs = require('fs');
var logger = require('raptor-logging').logger(module);
function testCompiler(path) { function testCompiler(path) {
var inputPath = nodePath.join(__dirname, path); var templatePath = nodePath.join(__dirname, path, 'template.marko');
var expectedPath = nodePath.join(__dirname, path + '.expected.js'); var expectedPath = nodePath.join(__dirname, path, 'expected.js');
var actualPath = nodePath.join(__dirname, path + '.actual.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); var output = compiler.compile(src);
fs.writeFileSync(actualPath, output, {encoding: 'utf8'}); fs.writeFileSync(actualPath, output, {encoding: 'utf8'});
@ -28,7 +26,7 @@ function testCompiler(path) {
} }
if (output !== expected) { 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---------'); '\n---------\nACTUAL (' + actualPath + '):\n---------\n' + output + '\n---------');
} }
} }
@ -50,15 +48,15 @@ describe('marko/compiler' , function() {
}); });
it('should compile a simple template', 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() { 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() { 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() { // 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'); // testCompiler('test-project/test-templates/include.marko');
// }); // });
}); });

View File

@ -89,7 +89,7 @@ describe('marko/dust' , function() {
} }
}; };
testRender('test-project/dust/async.dust', { testRender('fixtures/dust/async.dust', {
userIds: [0, 1, 2, 3], userIds: [0, 1, 2, 3],
userInfo: function(arg, callback) { userInfo: function(arg, callback) {
callback(null, users[arg.userId]); callback(null, users[arg.userId]);

View File

@ -5,20 +5,20 @@
"global-attribute": "boolean" "global-attribute": "boolean"
} }
}, },
"test-hello": "hello-tag.json", "test-hello": "taglib/hello-tag.json",
"test-simpleHello": { "test-simpleHello": {
"renderer": "./simple-hello-tag.js", "renderer": "./taglib/simple-hello-tag.js",
"attributes": { "attributes": {
"name": "string", "name": "string",
"adult": "boolean" "adult": "boolean"
} }
}, },
"test-tabs": { "test-tabs": {
"renderer": "./tabs-tag.js", "renderer": "./taglib/tabs-tag.js",
"var": "tabs" "var": "tabs"
}, },
"test-tab": { "test-tab": {
"renderer": "./tab-tag.js", "renderer": "./taglib/tab-tag.js",
"import-var": { "import-var": {
"tabs": "tabs" "tabs": "tabs"
}, },
@ -27,11 +27,11 @@
} }
}, },
"test-tabs-new": { "test-tabs-new": {
"renderer": "./tabs-new-tag.js", "renderer": "./taglib/tabs-new-tag.js",
"body-function": "buildTabs(__tabsHelper)" "body-function": "buildTabs(__tabsHelper)"
}, },
"test-tab-new": { "test-tab-new": {
"renderer": "./tab-new-tag.js", "renderer": "./taglib/tab-new-tag.js",
"import-var": { "import-var": {
"tabs": "__tabsHelper" "tabs": "__tabsHelper"
}, },
@ -40,7 +40,7 @@
} }
}, },
"test-dynamic-attributes": { "test-dynamic-attributes": {
"renderer": "./dynamic-attributes-tag.js", "renderer": "./taglib/dynamic-attributes-tag.js",
"attributes": { "attributes": {
"test": "string", "test": "string",
"*": { "*": {
@ -50,14 +50,14 @@
} }
}, },
"test-dynamic-attributes2": { "test-dynamic-attributes2": {
"renderer": "./dynamic-attributes-tag2.js", "renderer": "./taglib/dynamic-attributes-tag2.js",
"attributes": { "attributes": {
"test": "string", "test": "string",
"*": "string" "*": "string"
} }
}, },
"test-dynamic-attributes3": { "test-dynamic-attributes3": {
"renderer": "./dynamic-attributes-tag3.js", "renderer": "./taglib/dynamic-attributes-tag3.js",
"attributes": { "attributes": {
"test": "string", "test": "string",
"*": { "*": {
@ -67,20 +67,20 @@
} }
}, },
"test-popover": { "test-popover": {
"renderer": "./popover-tag.js", "renderer": "./taglib/popover-tag.js",
"attributes": { "attributes": {
"title": "string", "title": "string",
"content": "string" "content": "string"
} }
}, },
"test-page-title": { "test-page-title": {
"template": "./page-title-tag.marko", "template": "./taglib/page-title-tag.marko",
"attributes": { "attributes": {
"title": "string" "title": "string"
} }
}, },
"test-default-attributes": { "test-default-attributes": {
"renderer": "./default-attributes-tag.js", "renderer": "./taglib/default-attributes-tag.js",
"attributes": { "attributes": {
"prop1": "string", "prop1": "string",
"prop2": "integer", "prop2": "integer",
@ -95,9 +95,9 @@
} }
}, },
"test-template-tag-dynamic-attributes": { "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"] "taglib-imports": ["./package.json"]
} }

View File

@ -1,4 +1,4 @@
var marko = require('../../'); var marko = require('../../../');
exports.render = function(input, out) { exports.render = function(input, out) {
marko.render(require.resolve('./popover.marko'), { marko.render(require.resolve('./popover.marko'), {

View File

@ -1,4 +1,4 @@
var marko = require('../../'); var marko = require('../../../');
exports.render = function(input, out) { exports.render = function(input, out) {
var tabs = [], var tabs = [],

View File

@ -1,31 +1,31 @@
var marko = require('../../'); var marko = require('../../../');
exports.render = function(input, out) { exports.render = function(input, out) {
var tabs = [], var tabs = [],
activeFound = false; activeFound = false;
input.invokeBody({ input.invokeBody({
addTab: function(tab) { addTab: function(tab) {
if (tab.active) { if (tab.active) {
tab.activeFound = true; tab.activeFound = true;
} }
tab.id = "tab" + tabs.length; tab.id = "tab" + tabs.length;
tabs.push(tab); tabs.push(tab);
} }
}); });
if (!activeFound && tabs.length) { if (!activeFound && tabs.length) {
tabs[0].active = true; tabs[0].active = true;
} }
tabs.forEach(function(tab) { tabs.forEach(function(tab) {
tab.liClass = tab.active ? "active" : ""; tab.liClass = tab.active ? "active" : "";
tab.divClass = tab.active ? "tab-pane active" : "tab-pane"; tab.divClass = tab.active ? "tab-pane active" : "tab-pane";
}); });
marko.render(require.resolve('./tabs.marko'), { marko.render(require.resolve('./tabs.marko'), {
tabs: tabs tabs: tabs
}, out); }, out);
}; };

View File

@ -0,0 +1 @@
Hello $data.name!

View 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>

View 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>

View File

@ -0,0 +1 @@
testContextDatatestSharedData

View File

@ -0,0 +1 @@
1-An error has occurred!2-An error has occurred!

View File

@ -0,0 +1 @@
1 2 3

View File

@ -0,0 +1 @@
1 2 3 4 5 6 7 8 9

View File

@ -0,0 +1 @@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

View File

@ -0,0 +1 @@
Test promise

View File

@ -0,0 +1 @@
Server is busy!

View File

@ -0,0 +1 @@
1-A timeout has occurred!2-A timeout has occurred!

View File

@ -0,0 +1 @@
<a href="/foo">Some Link</a>Another Link

View 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>

View 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