Permalink
Browse files

[fix] Tests seem to match the API now. One test still fails, may be a…

…n actual regression.
  • Loading branch information...
1 parent 8934e2d commit d38f21911c476361f3a230ffb5b8d15400160266 @jfhbrook jfhbrook committed Nov 23, 2011
Showing with 6 additions and 64 deletions.
  1. +1 −2 test/api-test.js
  2. +0 −48 test/fixture1.js
  3. +5 −14 test/fixtures/common.js
View
@@ -3,9 +3,8 @@ var vows = require('vows'),
common = require('./fixtures/common');
vows.describe('merge data into markup').addBatch({
- 'when creating a new constructor and providing both data and markup': {
+ 'when providing both data and markup': {
'for simple template': common.createTest('simple'),
'for one level template': common.createTest('one-level'),
- 'for a template using data-bind': common.createTest('data-bind')
}
}).export(module);
View
@@ -1,48 +0,0 @@
-var Plates = require('../lib/plates');
-
-//
-// construct an instance
-//
-var plate = new Plates;
-
-//
-// construct an instance with the html and data as params.
-//
-
-// var plate = new Plates(html, data);
-
-//
-// set the html for an instance.
-//
-plate.html('<div id="foo"></div><div class="foo"><span id="test"></span></div>');
-
-//
-// get the html for an instance.
-//
-plate.html(); // `<div id="foo"></div><div class="foo"></div>`
-
-//
-// set the data for an instance.
-//
-plate.data({ "foo": "bar" });
-
-//
-// get the data for an instance.
-//
-plate.data(); // `{ "foo": "bar" }`
-
-//
-// bind the html and data for an instance.
-//
-console.log(plate.bind()); // `<div id="foo">bar</div><div class="foo"></div>`
-
-//
-// bind the html and data with explicit instructions detailing
-// the relationships between individual keys and the attribute
-// they should use.
-//
-// plate.bind({ "foo": "class" }); // `<div id="foo"></div><div class="foo">bar</div>`
-
-//
-//
-//
View
@@ -1,7 +1,7 @@
var common = exports,
assert = require('assert'),
fs = require('fs'),
- Plate = require('../../lib/plates');
+ Plates = require('../../lib/plates');
function get(name, extension) {
try {
@@ -12,17 +12,10 @@ function get(name, extension) {
}
};
-common.render = function(name, data, map, method) {
- var plate = new Plate(),
- html = get(name, 'html');
+common.render = function(name, data, map) {
+ var html = get(name, 'html');
- plate.html(html).data(data);
-
- if (method === 'bind') {
- return plate.bind(map);
- } else if (method === 'compile') {
- return plate.compile(map)(data);
- }
+ return Plates.bind(html, data, map);
};
common.createTest = function(name, map) {
@@ -32,13 +25,11 @@ common.createTest = function(name, map) {
this.data = JSON.parse(get(name, 'json') || "{}");
return {
- render: common.render(name, this.data, map, 'bind'),
- compile: common.render(name, this.data, map, 'compile')
+ render: common.render(name, this.data, map),
};
},
'should merge data to markup': function(result) {
assert.equal(result.render, this.out);
- assert.equal(result.compile, this.out);
}
};
};

0 comments on commit d38f219

Please sign in to comment.