Skip to content

Commit

Permalink
All tests passing with Stache as a plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Mar 13, 2014
1 parent 939f762 commit 7bdaa6a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
20 changes: 12 additions & 8 deletions test/pluginified/2.0.5.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4067,12 +4067,12 @@ var __m39 = (function () {
var renderer = can.view('renderer_test');
ok(can.isFunction(directResult), 'Renderer returned directly');
ok(can.isFunction(renderer), 'Renderer is a function');
equal(renderer({
equal(renderer.render({
test: 'working test'
}), 'This is a working test', 'Rendered');
renderer = can.view(can.test.path('view/test//template.ejs'));
ok(can.isFunction(renderer), 'Renderer is a function');
equal(renderer({
equal(renderer.render({
message: 'Rendered!'
}), '<h3>Rendered!</h3>', 'Synchronous template loaded and rendered'); // TODO doesn't get caught in Zepto for whatever reason
// raises(function() {
Expand Down Expand Up @@ -4163,7 +4163,8 @@ var __m39 = (function () {
div.appendChild(frag);
can.append(can.$('#qunit-test-area'), div);
equal(div.outerHTML.match(/__!!__/g), null, 'No __!!__ contained in HTML content');
can.view.nodeLists.unregister(domainList); //equal(can.$('#test-dropdown')[0].outerHTML, can.$('#test-dropdown2')[0].outerHTML, 'Live bound select and non-live bound select the same');
// can.view.nodeLists.unregister(domainList);
// equal(can.$('#test-dropdown')[0].outerHTML, can.$('#test-dropdown2')[0].outerHTML, 'Live bound select and non-live bound select the same');
});
test('Live binding on number inputs', function () {
var template = can.view.ejs('<input id="candy" type="number" value="<%== state.attr("number") %>" />');
Expand Down Expand Up @@ -4517,6 +4518,8 @@ var __m39 = (function () {
var __m41 = (function () {
module('can/view/ejs, rendering', {
setup: function () {
can.view.ext = '.ejs';

this.animals = [
'sloth',
'bear',
Expand Down Expand Up @@ -4937,7 +4940,7 @@ var __m41 = (function () {
obs.attr('attributes', 'some="newText"');
equal(p.getAttribute('some'), 'newText', 'attribute updated');
obs.removeAttr('message');
equal(span.innerHTML, 'undefined', 'text node value is undefined');
equal(span.innerHTML, '', 'text node value is undefined');
obs.attr('message', 'Warp drive, Mr. Sulu');
equal(span.innerHTML, 'Warp drive, Mr. Sulu', 'text node updated');
obs.removeAttr('show');
Expand Down Expand Up @@ -5394,10 +5397,10 @@ var __m41 = (function () {
});
test('recursive views of previously stolen files shouldn\'t fail', function () {
// Using preload to bypass steal dependency (necessary for "grunt test")
can.view.preload('view_ejs_test_indirect1_ejs', can.EJS({
can.view.preloadStringRenderer('view_ejs_test_indirect1_ejs', can.EJS({
text: '<ul>' + '<% unordered.each(function(item) { %>' + '<li>' + '<% if(item.ol) { %>' + '<%== can.view.render(can.test.path(\'view/ejs/test/indirect2.ejs\'), { ordered: item.ol }) %>' + '<% } else { %>' + '<%= item.toString() %>' + '<% } %>' + '</li>' + '<% }) %>' + '</ul>'
}));
can.view.preload('view_ejs_test_indirect2_ejs', can.EJS({
can.view.preloadStringRenderer('view_ejs_test_indirect2_ejs', can.EJS({
text: '<ol>' + '<% ordered.each(function(item) { %>' + '<li>' + '<% if(item.ul) { %>' + '<%== can.view.render(can.test.path(\'view/ejs/test/indirect1.ejs\'), { unordered: item.ul }) %>' + '<% } else { %>' + '<%= item.toString() %>' + '<% } %>' + '</li>' + '<% }) %>' + '</ol>'
}));
var unordered = new can.Map.List([{
Expand Down Expand Up @@ -7242,6 +7245,7 @@ var __m48 = (function () {

module("can/view/mustache, rendering", {
setup: function () {
can.view.ext = '.mustache';

this.animals = ['sloth', 'bear', 'monkey']
if (!this.animals.each) {
Expand Down Expand Up @@ -9222,7 +9226,7 @@ var __m48 = (function () {
test("can pass in partials", function () {
var hello = can.view(can.test.path('view/mustache/test/hello.mustache'));
var fancyName = can.view(can.test.path('view/mustache/test/fancy_name.mustache'));
var result = hello({
var result = hello.render({
name: "World"
}, {
partials: {
Expand All @@ -9235,7 +9239,7 @@ var __m48 = (function () {

test("can pass in helpers", function () {
var helpers = can.view(can.test.path('view/mustache/test/helper.mustache'));
var result = helpers({
var result = helpers.render({
name: "world"
}, {
helpers: {
Expand Down
6 changes: 4 additions & 2 deletions view/ejs/ejs_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
steal("can/model", "can/view/ejs", "can/test", function () {
module('can/view/ejs, rendering', {
setup: function () {
can.view.ext = '.ejs';

this.animals = [
'sloth',
'bear',
Expand Down Expand Up @@ -890,10 +892,10 @@ steal("can/model", "can/view/ejs", "can/test", function () {
});
test('recursive views of previously stolen files shouldn\'t fail', function () {
// Using preload to bypass steal dependency (necessary for "grunt test")
can.view.preload('view_ejs_test_indirect1_ejs', can.EJS({
can.view.preloadStringRenderer('view_ejs_test_indirect1_ejs', can.EJS({
text: '<ul>' + '<% unordered.each(function(item) { %>' + '<li>' + '<% if(item.ol) { %>' + '<%== can.view.render(can.test.path(\'view/ejs/test/indirect2.ejs\'), { ordered: item.ol }) %>' + '<% } else { %>' + '<%= item.toString() %>' + '<% } %>' + '</li>' + '<% }) %>' + '</ul>'
}));
can.view.preload('view_ejs_test_indirect2_ejs', can.EJS({
can.view.preloadStringRenderer('view_ejs_test_indirect2_ejs', can.EJS({
text: '<ol>' + '<% ordered.each(function(item) { %>' + '<li>' + '<% if(item.ul) { %>' + '<%== can.view.render(can.test.path(\'view/ejs/test/indirect1.ejs\'), { unordered: item.ul }) %>' + '<% } else { %>' + '<%= item.toString() %>' + '<% } %>' + '</li>' + '<% }) %>' + '</ol>'
}));
var unordered = new can.Map.List([{
Expand Down
5 changes: 5 additions & 0 deletions view/mustache/mustache_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ steal("can/model", "can/view/mustache", "can/test", function () {

module("can/view/mustache, rendering", {
setup: function () {
can.view.ext = '.mustache';

this.animals = ['sloth', 'bear', 'monkey']
if (!this.animals.each) {
Expand Down Expand Up @@ -220,6 +221,8 @@ steal("can/model", "can/view/mustache", "can/test", function () {
// now update the named attribute
obsvr.attr('named', true);
deepEqual(can.$('#completed')[0].innerHTML, "", 'hidden gone');

can.remove(can.$('#qunit-test-area *'));
});

test("Mustache live-binding with escaping", function () {
Expand All @@ -242,6 +245,8 @@ steal("can/model", "can/view/mustache", "can/test", function () {

deepEqual(can.$('#binder1')[0].innerHTML, "&lt;i&gt;Mr Scott&lt;/i&gt;");
deepEqual(can.$('#binder2')[0].getElementsByTagName('i')[0].innerHTML, "Mr Scott")

can.remove(can.$('#qunit-test-area *'));
});

test("Mustache truthy", function () {
Expand Down
5 changes: 5 additions & 0 deletions view/stache/stache_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ steal("can/view/stache", "can/view","can/test",function(){

module("can/view/stache",{
setup: function(){
can.view.ext = '.stache';
this.animals = ['sloth', 'bear', 'monkey'];
}
});
Expand Down Expand Up @@ -280,6 +281,8 @@ steal("can/view/stache", "can/view","can/test",function(){
// now update the named attribute
obsvr.attr('named', true);
deepEqual(can.$('#completed')[0].innerHTML, "", 'hidden gone');

can.remove(can.$('#qunit-test-area *'));
});

test("live-binding with escaping", function () {
Expand All @@ -300,6 +303,8 @@ steal("can/view/stache", "can/view","can/test",function(){

deepEqual(can.$('#binder1')[0].innerHTML, "&lt;i&gt;Mr Scott&lt;/i&gt;");
deepEqual(can.$('#binder2')[0].getElementsByTagName('i')[0].innerHTML, "Mr Scott");

can.remove(can.$('#qunit-test-area *'));
});

test("truthy", function () {
Expand Down
2 changes: 2 additions & 0 deletions view/view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ steal("can/view/callbacks",
if (window.require) {
if (window.require.config && window.require.toUrl) {
test('template files relative to requirejs baseUrl (#647)', function () {
can.view.ext = '.mustache';

var oldBaseUrl = window.requirejs.s.contexts._.config.baseUrl;
window.require.config({
baseUrl: oldBaseUrl + '/view/test/'
Expand Down

0 comments on commit 7bdaa6a

Please sign in to comment.