From 6b74387241bdae1d4242018d13c5416ee6607799 Mon Sep 17 00:00:00 2001 From: Cherif BOUCHELAGHEM Date: Fri, 10 May 2019 18:53:49 +0100 Subject: [PATCH 1/2] Landscaper: QUnit2 upgrade --- helpers/-and-or-test.js | 70 +- helpers/-converter-test.js | 40 +- helpers/-each-test.js | 34 +- helpers/-for-of-test.js | 40 +- helpers/-if-test.js | 34 +- helpers/-is-test.js | 24 +- helpers/-let-test.js | 44 +- helpers/-portal-test.js | 66 +- package.json | 2 +- test/expression-test.js | 252 ++--- test/filename-test.js | 24 +- test/nodelist-test.js | 4 +- test/partials-test.js | 146 +-- test/stache-define-test.js | 88 +- test/stache-test.js | 2088 ++++++++++++++++++------------------ test/test.js | 2 +- test/warnings-test.js | 66 +- 17 files changed, 1512 insertions(+), 1512 deletions(-) diff --git a/helpers/-and-or-test.js b/helpers/-and-or-test.js index 409ab85b..76021cfe 100644 --- a/helpers/-and-or-test.js +++ b/helpers/-and-or-test.js @@ -6,7 +6,7 @@ var Observation = require("can-observation"); QUnit.module("can-stache and/or helper"); -QUnit.test("and standalone", function(){ +QUnit.test("and standalone", function(assert) { var renders = []; var view = stache("
{{#and(a,b)}}{{truthy(this)}}{{else}}{{falsey(this)}}{{/and}}
"); @@ -17,25 +17,25 @@ QUnit.test("and standalone", function(){ }); map.set("truthy", function(that){ - QUnit.equal(that, map, "truthy this is right"); + assert.equal(that, map, "truthy this is right"); renders.push("truthy"); return "truthy"; }); map.set("falsey", function(that){ - QUnit.equal(that, map, "falsey this is right"); + assert.equal(that, map, "falsey this is right"); renders.push("falsey"); return "falsey"; }); var frag = view(map); - QUnit.equal( frag.firstChild.innerHTML, "truthy", "1,1" ); + assert.equal( frag.firstChild.innerHTML, "truthy", "1,1" ); // 2,2 ... stays truthy canReflect.assign(map, { a: 2, b: 2 }); - QUnit.equal( frag.firstChild.innerHTML, "truthy", "2,2" ); - QUnit.deepEqual(renders,["truthy"], "2,2 render"); + assert.equal( frag.firstChild.innerHTML, "truthy", "2,2" ); + assert.deepEqual(renders,["truthy"], "2,2 render"); renders = []; // 0,2 @@ -43,8 +43,8 @@ QUnit.test("and standalone", function(){ a: 0, b: 2 }); - QUnit.equal( frag.firstChild.innerHTML, "falsey", "0,2" ); - QUnit.deepEqual(renders,["falsey"], "0,2 render"); + assert.equal( frag.firstChild.innerHTML, "falsey", "0,2" ); + assert.deepEqual(renders,["falsey"], "0,2 render"); renders = []; // false, "" @@ -52,11 +52,11 @@ QUnit.test("and standalone", function(){ a: false, b: "" }); - QUnit.equal( frag.firstChild.innerHTML, "falsey", "false,''" ); - QUnit.deepEqual(renders,[]); + assert.equal( frag.firstChild.innerHTML, "falsey", "false,''" ); + assert.deepEqual(renders,[]); }); -QUnit.test("and as call expression", function(){ +QUnit.test("and as call expression", function(assert) { var renders = []; var view = stache("
{{#eq( and(a,b), c) }}{{truthy(this)}}{{else}}{{falsey(this)}}{{/eq}}
"); @@ -68,24 +68,24 @@ QUnit.test("and as call expression", function(){ }); map.set("truthy", function(that){ - QUnit.equal(that, map, "truthy this is right"); + assert.equal(that, map, "truthy this is right"); renders.push("truthy"); return "truthy"; }); map.set("falsey", function(that){ - QUnit.equal(that, map, "falsey this is right"); + assert.equal(that, map, "falsey this is right"); renders.push("falsey"); return "falsey"; }); var frag = view(map); - QUnit.equal( frag.firstChild.innerHTML, "truthy", "(1 && 1 ) === 1" ); + assert.equal( frag.firstChild.innerHTML, "truthy", "(1 && 1 ) === 1" ); // 2,2 ... stays truthy canReflect.assign(map, { a: 2, }); - QUnit.equal( frag.firstChild.innerHTML, "truthy", "(2 && 1 ) === 1" ); - QUnit.deepEqual(renders,["truthy"]); + assert.equal( frag.firstChild.innerHTML, "truthy", "(2 && 1 ) === 1" ); + assert.deepEqual(renders,["truthy"]); renders = []; // 2,0 @@ -93,8 +93,8 @@ QUnit.test("and as call expression", function(){ a: 2, b: 0 }); - QUnit.equal( frag.firstChild.innerHTML, "falsey", "(2 && 0 ) === 1" ); - QUnit.deepEqual(renders,["falsey"]); + assert.equal( frag.firstChild.innerHTML, "falsey", "(2 && 0 ) === 1" ); + assert.deepEqual(renders,["falsey"]); renders = []; // false, "" @@ -102,12 +102,12 @@ QUnit.test("and as call expression", function(){ a: false, b: "" }); - QUnit.equal( frag.firstChild.innerHTML, "falsey", "(false && '' ) === 1" ); - QUnit.deepEqual(renders,[]); + assert.equal( frag.firstChild.innerHTML, "falsey", "(false && '' ) === 1" ); + assert.deepEqual(renders,[]); }); -QUnit.test("or standalone", function(){ +QUnit.test("or standalone", function(assert) { var renders = []; var view = stache("
{{#or(a,b)}}{{truthy(this)}}{{else}}{{falsey(this)}}{{/or}}
"); @@ -118,25 +118,25 @@ QUnit.test("or standalone", function(){ }); map.set("truthy", function(that){ - QUnit.equal(that, map, "truthy this is right"); + assert.equal(that, map, "truthy this is right"); renders.push("truthy"); return "truthy"; }); map.set("falsey", function(that){ - QUnit.equal(that, map, "falsey this is right"); + assert.equal(that, map, "falsey this is right"); renders.push("falsey"); return "falsey"; }); var frag = view(map); - QUnit.equal( frag.firstChild.innerHTML, "truthy", "1,1" ); + assert.equal( frag.firstChild.innerHTML, "truthy", "1,1" ); // 2,2 ... stays truthy canReflect.assign(map, { a: 0, b: 2 }); - QUnit.equal( frag.firstChild.innerHTML, "truthy", "0,2" ); - QUnit.deepEqual(renders,["truthy"], "0,2 render"); + assert.equal( frag.firstChild.innerHTML, "truthy", "0,2" ); + assert.deepEqual(renders,["truthy"], "0,2 render"); renders = []; // 0,2 @@ -144,8 +144,8 @@ QUnit.test("or standalone", function(){ a: 0, b: 0 }); - QUnit.equal( frag.firstChild.innerHTML, "falsey", "0,0" ); - QUnit.deepEqual(renders,["falsey"], "0,0 render"); + assert.equal( frag.firstChild.innerHTML, "falsey", "0,0" ); + assert.deepEqual(renders,["falsey"], "0,0 render"); renders = []; // false, "" @@ -153,30 +153,30 @@ QUnit.test("or standalone", function(){ a: false, b: "" }); - QUnit.equal( frag.firstChild.innerHTML, "falsey", "false,''" ); - QUnit.deepEqual(renders,[]); + assert.equal( frag.firstChild.innerHTML, "falsey", "false,''" ); + assert.deepEqual(renders,[]); }); -QUnit.test("and is lazy", function(){ +QUnit.test("and is lazy", function(assert) { var view = stache("
{{#and(this.isFalse, this.shouldNotBeRead)}}TRUE{{else}}FALSE{{/and}}
"); var fragment = view({ isFalse: false, shouldNotBeRead: new Observation(function avoidReadingThis(){ - QUnit.ok(false, "should not be read"); + assert.ok(false, "should not be read"); }) }); - QUnit.equal(fragment.firstChild.innerHTML,"FALSE", "evaled to false"); + assert.equal(fragment.firstChild.innerHTML,"FALSE", "evaled to false"); view = stache("
{{#and(this.isFalse, this.functionCall() )}}TRUE{{else}}FALSE{{/and}}
"); fragment = view({ isFalse: false, functionCall: function(){ - QUnit.ok(false, "should not be read"); + assert.ok(false, "should not be read"); } }); - QUnit.equal(fragment.firstChild.innerHTML,"FALSE", "evaled to false"); + assert.equal(fragment.firstChild.innerHTML,"FALSE", "evaled to false"); }); diff --git a/helpers/-converter-test.js b/helpers/-converter-test.js index 39061841..c3881539 100644 --- a/helpers/-converter-test.js +++ b/helpers/-converter-test.js @@ -10,7 +10,7 @@ var stache = require("can-stache"); QUnit.module("can-stache converters"); -QUnit.test("addLiveConverter helpers push and pull correct values", function () { +QUnit.test("addLiveConverter helpers push and pull correct values", function(assert) { helpers.addConverter('numberToHex', { get: function(val) { @@ -32,12 +32,12 @@ QUnit.test("addLiveConverter helpers push and pull correct values", function () //var renderer = stache(''); - equal(twoWayCompute.get(), 'ff', 'Converter called'); + assert.equal(twoWayCompute.get(), 'ff', 'Converter called'); twoWayCompute.set('7f'); - equal(data.get("observeVal"), 127, 'push converter called'); + assert.equal(data.get("observeVal"), 127, 'push converter called'); }); -QUnit.test("addConverter helpers push and pull multiple values", function () { +QUnit.test("addConverter helpers push and pull multiple values", function(assert) { helpers.addConverter('isInList', { get: function(valCompute, list) { @@ -63,23 +63,23 @@ QUnit.test("addConverter helpers push and pull multiple values", function () { //var renderer = stache(''); - equal(twoWayCompute.get(), false, 'Converter called'); + assert.equal(twoWayCompute.get(), false, 'Converter called'); twoWayCompute.set(5); - deepEqual(data.attr("list").attr(), [1,2,3,5], 'push converter called'); + assert.deepEqual(data.attr("list").attr(), [1,2,3,5], 'push converter called'); }); -QUnit.test("Can register multiple converters at once with addConverter", function(){ +QUnit.test("Can register multiple converters at once with addConverter", function(assert) { QUnit.expect(2); var converters = { "converter-one": { get: function(){ - QUnit.ok(true, "converter-one called"); + assert.ok(true, "converter-one called"); }, set: function(){} }, "converter-two": { get: function(){ - QUnit.ok(true, "converter-two called"); + assert.ok(true, "converter-two called"); }, set: function(){} } @@ -100,7 +100,7 @@ QUnit.test("Can register multiple converters at once with addConverter", functio QUnit.module("can-stache converters - not"); -QUnit.test("saves the inverse of the selected value without ~ (#68)", function(){ +QUnit.test("saves the inverse of the selected value without ~ (#68)", function(assert) { var data = new SimpleMap({ val: true }); @@ -110,13 +110,13 @@ QUnit.test("saves the inverse of the selected value without ~ (#68)", function() var value = expr.value(scope); - QUnit.equal( value.get(), false , "read the value"); + assert.equal( value.get(), false , "read the value"); value.set(true); - QUnit.equal( data.get("val"), false ,"able to change the value" ); + assert.equal( data.get("val"), false ,"able to change the value" ); }); -QUnit.test("not works also like if", function(){ +QUnit.test("not works also like if", function(assert) { var view = stache("
{{# not(this.value) }}{{truthy(this)}}{{else}}FALSY{{/not}}
"); var data = new SimpleMap({ @@ -125,18 +125,18 @@ QUnit.test("not works also like if", function(){ var frag = view(data,{ truthy: function(that){ - QUnit.equal(that, data, "has the right scope"); + assert.equal(that, data, "has the right scope"); return "TRUTHY"; } }); - QUnit.equal(frag.firstChild.innerHTML, "TRUTHY"); + assert.equal(frag.firstChild.innerHTML, "TRUTHY"); data.set("value", true); - QUnit.equal(frag.firstChild.innerHTML, "FALSY"); + assert.equal(frag.firstChild.innerHTML, "FALSY"); }); -QUnit.test("not works inside if", function(){ +QUnit.test("not works inside if", function(assert) { var view = stache("
{{#if( not(this.value) ) }}{{truthy(this)}}{{else}}FALSY{{/if}}
"); var data = new SimpleMap({ @@ -145,13 +145,13 @@ QUnit.test("not works inside if", function(){ var frag = view(data,{ truthy: function(that){ - QUnit.equal(that, data, "has the right scope"); + assert.equal(that, data, "has the right scope"); return "TRUTHY"; } }); - QUnit.equal(frag.firstChild.innerHTML, "TRUTHY"); + assert.equal(frag.firstChild.innerHTML, "TRUTHY"); data.set("value", true); - QUnit.equal(frag.firstChild.innerHTML, "FALSY"); + assert.equal(frag.firstChild.innerHTML, "FALSY"); }); diff --git a/helpers/-each-test.js b/helpers/-each-test.js index b5d21f4a..1c5b9786 100644 --- a/helpers/-each-test.js +++ b/helpers/-each-test.js @@ -9,7 +9,7 @@ var SimpleMap = require("can-simple-map"); QUnit.module("can-stache #each helper"); -test("each with sort (#498)", function(){ +QUnit.test("each with sort (#498)", function(assert) { var template = stache("
{{#each(list)}}

{{.}}

{{/each}}
"); var list = new DefineList([34234,2,1,3]); @@ -22,11 +22,11 @@ test("each with sort (#498)", function(){ return +p.firstChild.nodeValue; }); - deepEqual(order, [1,2,3,34234]); + assert.deepEqual(order, [1,2,3,34234]); }); -QUnit.test("#each throws error (can-stache-bindings#444)", function(){ +QUnit.test("#each throws error (can-stache-bindings#444)", function(assert) { var list = new DefineList([ {name: 'A'}, {name: 'B'}, @@ -59,10 +59,11 @@ QUnit.test("#each throws error (can-stache-bindings#444)", function(){ }, data, []); queues.batch.stop(); - QUnit.ok(true, "no errors"); + assert.ok(true, "no errors"); }); -QUnit.asyncTest("if within an each", function(){ +QUnit.test("if within an each", function(assert) { + var ready = assert.async(); var template = stache("
{{# each(sortedMonthlyOSProjects ) }}{{# if(val) }}Hi{{/ if }}{{/ each }}
"); var osProject1 = { @@ -90,16 +91,15 @@ QUnit.asyncTest("if within an each", function(){ setTimeout(function(){ osProject1.val.set(true); - QUnit.ok(true,"no errors"); - QUnit.start(); + assert.ok(true,"no errors"); + ready(); },20); //osProject2.val.set(false); - }); -test("changing the list works with each", function () { +QUnit.test("changing the list works with each", function(assert) { var template = stache(""); @@ -108,18 +108,18 @@ test("changing the list works with each", function () { }); var tpl = template(map).firstChild; - equal(tpl.getElementsByTagName('li').length, 1, "one li"); + assert.equal(tpl.getElementsByTagName('li').length, 1, "one li"); var fooLi = tpl.getElementsByTagName('li')[0]; map.set("list", new DefineList(["foo", "car"])); - QUnit.equal(tpl.getElementsByTagName('li').length, 2, "two lis"); - QUnit.equal(fooLi, tpl.getElementsByTagName('li')[0], "retains the same li"); + assert.equal(tpl.getElementsByTagName('li').length, 2, "two lis"); + assert.equal(fooLi, tpl.getElementsByTagName('li')[0], "retains the same li"); }); -test("changing the list from undefined to defined", function () { +QUnit.test("changing the list from undefined to defined", function(assert) { var template = stache(""); @@ -128,17 +128,17 @@ test("changing the list from undefined to defined", function () { }); var tpl = template(map).firstChild; - equal(tpl.getElementsByTagName('li').length, 0, "no li"); + assert.equal(tpl.getElementsByTagName('li').length, 0, "no li"); var list = new DefineList(["foo", "car"]); map.set("list", list); - QUnit.equal(tpl.getElementsByTagName('li').length, 2, "two lis"); + assert.equal(tpl.getElementsByTagName('li').length, 2, "two lis"); var fooLi = tpl.getElementsByTagName('li')[1]; list.shift(); - QUnit.equal(tpl.getElementsByTagName('li').length, 1, "one lis"); - QUnit.equal(fooLi, tpl.getElementsByTagName('li')[0], "retains the same li"); + assert.equal(tpl.getElementsByTagName('li').length, 1, "one lis"); + assert.equal(fooLi, tpl.getElementsByTagName('li')[0], "retains the same li"); }); diff --git a/helpers/-for-of-test.js b/helpers/-for-of-test.js index 9bf3a397..f8e7d37b 100644 --- a/helpers/-for-of-test.js +++ b/helpers/-for-of-test.js @@ -9,7 +9,7 @@ require("./-for-of"); QUnit.module("can-stache #for(of) helper"); -test("basics", function(){ +QUnit.test("basics", function(assert) { var template = stache("
{{#for(value of list)}}

{{this.vmProp}}{{value}}

{{/for}}
"); var list = new DefineList([34234,2,1,3]); @@ -24,7 +24,7 @@ test("basics", function(){ return +p.innerHTML; }); - deepEqual(order, [11,12,13,134234]); + assert.deepEqual(order, [11,12,13,134234]); @@ -57,10 +57,10 @@ test("basics", function(){ }; var result = template(vm).firstChild.innerHTML.replace(/\s+/g," "); - QUnit.equal(result, "Hello, you have 1.
Justin
"); + assert.equal(result, "Hello, you have 1.
Justin
"); }); -QUnit.test("create an observable let scope (#593)", function(){ +QUnit.test("create an observable let scope (#593)", function(assert) { var template = stache("
{{# for(thing of this.stuff)}}"+ "{{let theValue=null}}"+ "{{write theValue}}"+ @@ -80,13 +80,13 @@ QUnit.test("create an observable let scope (#593)", function(){ var labels = frag.firstChild.getElementsByTagName("label"); - QUnit.equal(labels[0].innerHTML,"1", "first element"); - QUnit.equal(labels[1].innerHTML,"2", "first element"); + assert.equal(labels[0].innerHTML,"1", "first element"); + assert.equal(labels[1].innerHTML,"2", "first element"); }); -QUnit.test("works with non observables", function(){ +QUnit.test("works with non observables", function(assert) { var template = stache("
{{#for(value of list)}}

{{this.vmProp}}{{value}}

{{/for}}
"); var list = [34234,2,1,3]; var frag = template({ @@ -98,42 +98,42 @@ QUnit.test("works with non observables", function(){ return +p.innerHTML; }); - deepEqual(order, [134234,12,11,13]); + assert.deepEqual(order, [134234,12,11,13]); }); -QUnit.test("works as string only", function(){ +QUnit.test("works as string only", function(assert) { var template = stache("
"); var list = [1,2,3]; var frag = template({ list: list, vmProp: "a" }); - QUnit.equal( frag.firstChild.className, "[a-1][a-2][a-3]"); + assert.equal( frag.firstChild.className, "[a-1][a-2][a-3]"); }); -QUnit.test("scope.index works", function(){ +QUnit.test("scope.index works", function(assert) { var template = stache("
{{#for(value of list)}}[{{scope.index}}]{{/for}}
"); var list = ["a","b","c"]; var frag = template({ list: list, vmProp: "a" }); - QUnit.equal( frag.firstChild.innerHTML, "[0][1][2]"); + assert.equal( frag.firstChild.innerHTML, "[0][1][2]"); }); -QUnit.test("for(list) works", function(){ +QUnit.test("for(list) works", function(assert) { var template = stache("
{{#for(list)}}[{{scope.index}}]{{/for}}
"); var list = ["a","b","c"]; var frag = template({ list: list, vmProp: "a" }); - QUnit.equal( frag.firstChild.innerHTML, "[0][1][2]"); + assert.equal( frag.firstChild.innerHTML, "[0][1][2]"); }); -QUnit.test("for(value of object) works in a string", function(){ +QUnit.test("for(value of object) works in a string", function(assert) { var template = stache("
"); var object = { first: "FIRST", @@ -143,19 +143,19 @@ QUnit.test("for(value of object) works in a string", function(){ object: object }); - QUnit.equal( frag.firstChild.className, "[first-FIRST][second-SECOND]"); + assert.equal( frag.firstChild.className, "[first-FIRST][second-SECOND]"); }); -QUnit.test("else contains the correct this", function() { +QUnit.test("else contains the correct this", function(assert) { var template = stache("{{#for(item of items)}}ITEM{{else}}{{this.message}}{{/for}}"); var frag = template({ items: [], message: "empty" }); - QUnit.equal(frag.firstChild.nextSibling.nodeValue, "empty", "got the value from the VM"); + assert.equal(frag.firstChild.nextSibling.nodeValue, "empty", "got the value from the VM"); }); -QUnit.test("forOf works after calling helpersCore.__resetHelpers", function() { +QUnit.test("forOf works after calling helpersCore.__resetHelpers", function(assert) { helpersCore.__resetHelpers(); var template = stache("
{{#for(value of list)}}

{{this.vmProp}}{{value}}

{{/for}}
"); @@ -170,5 +170,5 @@ QUnit.test("forOf works after calling helpersCore.__resetHelpers", function() { return +p.innerHTML; }); - deepEqual(order, [11,12,13,134234]); + assert.deepEqual(order, [11,12,13,134234]); }); diff --git a/helpers/-if-test.js b/helpers/-if-test.js index 4f0497c2..1f841184 100644 --- a/helpers/-if-test.js +++ b/helpers/-if-test.js @@ -12,7 +12,7 @@ QUnit.module("can-stache if helper"); -QUnit.test("Stache with boolean property with {{#if}}", function() { +QUnit.test("Stache with boolean property with {{#if}}", function(assert) { var nailedIt = 'Nailed it'; var Example = define.Constructor({ name: { @@ -48,10 +48,10 @@ QUnit.test("Stache with boolean property with {{#if}}", function() { var nested = new NestedMap(); var template = stache('{{#if isEnabled}}Enabled{{/if}}'); var frag = template(nested); - equal(frag.firstChild.nodeValue, 'Enabled'); + assert.equal(frag.firstChild.nodeValue, 'Enabled'); }); -QUnit.test("#each with #if directly nested (#750)", function(){ +QUnit.test("#each with #if directly nested (#750)", function(assert) { var template = stache(""); var data = new SimpleMap( { @@ -75,24 +75,24 @@ QUnit.test("#each with #if directly nested (#750)", function(){ data.get('list').pop(); - equal(frag.firstChild.getElementsByTagName('li').length, 1, "only first should be visible"); + assert.equal(frag.firstChild.getElementsByTagName('li').length, 1, "only first should be visible"); }); -QUnit.test("call expression with #if", function(){ +QUnit.test("call expression with #if", function(assert) { var truthy = new SimpleObservable(true); var template = stache("{{#if(truthy)}}true{{else}}false{{/if}}"); var frag = template({truthy: truthy}); - equal( frag.firstChild.nodeValue, "true", "set to true"); + assert.equal( frag.firstChild.nodeValue, "true", "set to true"); truthy.set(false); - equal( frag.firstChild.nodeValue, "false", "set to false"); + assert.equal( frag.firstChild.nodeValue, "false", "set to false"); }); -test("#if works with call expressions", function(){ +QUnit.test("#if works with call expressions", function(assert) { var template = stache("{{#if(foo)}}foo{{else}}bar{{/if}}"); var map = new DefineMap({ foo: true @@ -101,23 +101,23 @@ test("#if works with call expressions", function(){ var frag = template(map); div.appendChild(frag); - QUnit.equal(div.innerHTML, "foo"); + assert.equal(div.innerHTML, "foo"); map.foo = false; - QUnit.equal(div.innerHTML, "bar"); + assert.equal(div.innerHTML, "bar"); }); -QUnit.test("Inverse {{if}} doesn't render truthy section when value is truthy", function(){ +QUnit.test("Inverse {{if}} doesn't render truthy section when value is truthy", function(assert) { var div = document.createElement("div"); var view = stache("{{^if(isTrue())}}did not work{{/if}}"); var frag = view({ isTrue: function() { return true; } }); div.appendChild(frag); - equal(div.innerHTML, "", "No textnode rendered"); + assert.equal(div.innerHTML, "", "No textnode rendered"); }); -QUnit.test("#if should not re-render children", function(){ +QUnit.test("#if should not re-render children", function(assert) { var count = 0; var view = stache("{{#if(person.name)}} {{increment()}} {{/if}}"); var map = new DefineMap({ @@ -131,10 +131,10 @@ QUnit.test("#if should not re-render children", function(){ map.person.name = "Kevin"; map.person.name = "Justin"; - QUnit.equal(count, 1, "count should be called only once"); + assert.equal(count, 1, "count should be called only once"); }); -test("Handlebars helper: if/else", function () { +QUnit.test("Handlebars helper: if/else", function(assert) { var expected; var t = { template: "{{#if name}}{{name}}{{/if}}{{#if missing}} is missing!{{/if}}", @@ -147,10 +147,10 @@ test("Handlebars helper: if/else", function () { expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual(stacheTestHelpers.getText(t.template,t.data), expected); + assert.deepEqual(stacheTestHelpers.getText(t.template,t.data), expected); t.data.missing = null; expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual(stacheTestHelpers.getText(t.template,t.data), expected); + assert.deepEqual(stacheTestHelpers.getText(t.template,t.data), expected); }); diff --git a/helpers/-is-test.js b/helpers/-is-test.js index b35b5104..4fb4fcc9 100644 --- a/helpers/-is-test.js +++ b/helpers/-is-test.js @@ -7,7 +7,7 @@ var stacheTestHelpers = require("../test/helpers")(document); QUnit.module("can-stache is/eq helper"); -QUnit.test("#if should not re-render children", function(){ +QUnit.test("#if should not re-render children", function(assert) { var count = 0; var view = stache("{{#eq(a,b)}} {{increment()}} {{/eq}}"); var map = new DefineMap({ @@ -29,11 +29,11 @@ QUnit.test("#if should not re-render children", function(){ b: 3 }); - QUnit.equal(count, 1, "count should be called only once"); + assert.equal(count, 1, "count should be called only once"); }); -QUnit.test("#eq works with call expressions", function(){ +QUnit.test("#eq works with call expressions", function(assert) { var template = stache("{{#eq(foo, true)}}foo{{else}}bar{{/eq}}"); var map = new DefineMap({ foo: true @@ -42,12 +42,12 @@ QUnit.test("#eq works with call expressions", function(){ var frag = template(map); div.appendChild(frag); - QUnit.equal(div.innerHTML, "foo"); + assert.equal(div.innerHTML, "foo"); map.foo = false; - QUnit.equal(div.innerHTML, "bar"); + assert.equal(div.innerHTML, "bar"); }); -QUnit.test("#is works with call expressions", function(){ +QUnit.test("#is works with call expressions", function(assert) { var template = stache("{{#is(foo, true)}}foo{{else}}bar{{/eq}}"); var map = new DefineMap({ foo: true @@ -56,12 +56,12 @@ QUnit.test("#is works with call expressions", function(){ var frag = template(map); div.appendChild(frag); - QUnit.equal(div.innerHTML, "foo"); + assert.equal(div.innerHTML, "foo"); map.foo = false; - QUnit.equal(div.innerHTML, "bar"); + assert.equal(div.innerHTML, "bar"); }); -QUnit.test("Handlebars helper: is/else (with 'eq' alias)", function() { +QUnit.test("Handlebars helper: is/else (with 'eq' alias)", function(assert) { var expected; var t = { template: '{{#eq ducks tenDucks "10"}}10 ducks{{else}}Not 10 ducks{{/eq}}', @@ -81,12 +81,12 @@ QUnit.test("Handlebars helper: is/else (with 'eq' alias)", function() { }; expected = t.expected.replace(/"/g, '"').replace(/\r\n/g, '\n'); - deepEqual(stacheTestHelpers.getText(t.template, t.data), expected); + assert.deepEqual(stacheTestHelpers.getText(t.template, t.data), expected); - deepEqual(stacheTestHelpers.getText(t.template, t.liveData), expected); + assert.deepEqual(stacheTestHelpers.getText(t.template, t.liveData), expected); t.data.ducks = 5; - deepEqual(stacheTestHelpers.getText(t.template, t.data), 'Not 10 ducks'); + assert.deepEqual(stacheTestHelpers.getText(t.template, t.data), 'Not 10 ducks'); }); diff --git a/helpers/-let-test.js b/helpers/-let-test.js index ca502039..c70e77ec 100644 --- a/helpers/-let-test.js +++ b/helpers/-let-test.js @@ -9,7 +9,7 @@ require("./-let"); QUnit.module("can-stache let helper"); -QUnit.test("basics without commas", function(){ +QUnit.test("basics without commas", function(assert) { var template = stache( "{{let userName=this.name constTwo=2}}"+ @@ -19,14 +19,14 @@ QUnit.test("basics without commas", function(){ var frag = template(vm); - QUnit.equal( frag.lastChild.innerHTML, "Justin", "got initial value"); + assert.equal( frag.lastChild.innerHTML, "Justin", "got initial value"); vm.name = "Ramiya"; - QUnit.equal( frag.lastChild.innerHTML, "Ramiya", "value updated"); + assert.equal( frag.lastChild.innerHTML, "Ramiya", "value updated"); }); -QUnit.test("basics with commas", function(){ +QUnit.test("basics with commas", function(assert) { var template = stache( "{{let userName=this.name, constTwo=2}}"+ @@ -36,14 +36,14 @@ QUnit.test("basics with commas", function(){ var frag = template(vm); - QUnit.equal( frag.lastChild.innerHTML, "Justin-2", "got initial value"); + assert.equal( frag.lastChild.innerHTML, "Justin-2", "got initial value"); vm.name = "Ramiya"; - QUnit.equal( frag.lastChild.innerHTML, "Ramiya-2", "value updated"); + assert.equal( frag.lastChild.innerHTML, "Ramiya-2", "value updated"); }); -QUnit.test("make undefined variables settable", function(){ +QUnit.test("make undefined variables settable", function(assert) { var template = stache( "{{ let userName=undefined }}"+ "
{{userName}} {{changeUserName(scope)}}
" @@ -58,17 +58,17 @@ QUnit.test("make undefined variables settable", function(){ scope.set("userName","Justin"); - QUnit.deepEqual( frag.lastChild.firstChild.nodeValue, "Justin"); + assert.deepEqual( frag.lastChild.firstChild.nodeValue, "Justin"); }); -QUnit.test("custom scopes still get a let context", function(){ +QUnit.test("custom scopes still get a let context", function(assert) { var template = stache("{{let foo='bar'}}"); template(new Scope({})); - QUnit.ok(true, "passes"); + assert.ok(true, "passes"); }); -QUnit.test("let blocks allow reassigning variables #645", function(){ +QUnit.test("let blocks allow reassigning variables #645", function(assert) { var template = stache( "{{#let foo='bar'}}" + "

{{foo}}

" + @@ -80,12 +80,12 @@ QUnit.test("let blocks allow reassigning variables #645", function(){ ); var frag = template(new Scope({})); var paragraphs = frag.querySelectorAll('p'); - QUnit.equal( paragraphs[0].innerHTML, "bar", "first value still works"); - QUnit.equal( paragraphs[1].innerHTML, "baz", "reassigning foo works"); - QUnit.equal( paragraphs[2].innerHTML, "foo-", "foo is not available outside of let block"); + assert.equal( paragraphs[0].innerHTML, "bar", "first value still works"); + assert.equal( paragraphs[1].innerHTML, "baz", "reassigning foo works"); + assert.equal( paragraphs[2].innerHTML, "foo-", "foo is not available outside of let block"); }); -QUnit.test("let works after calling helpersCore.__resetHelpers", function() { +QUnit.test("let works after calling helpersCore.__resetHelpers", function(assert) { helpersCore.__resetHelpers(); var template = stache( @@ -96,14 +96,14 @@ QUnit.test("let works after calling helpersCore.__resetHelpers", function() { var frag = template(vm); - QUnit.equal( frag.lastChild.innerHTML, "Justin", "got initial value"); + assert.equal( frag.lastChild.innerHTML, "Justin", "got initial value"); vm.name = "Ramiya"; - QUnit.equal( frag.lastChild.innerHTML, "Ramiya", "value updated"); + assert.equal( frag.lastChild.innerHTML, "Ramiya", "value updated"); }); -QUnit.test("let multiple updates (#650)", function(){ +QUnit.test("let multiple updates (#650)", function(assert) { // This is actually testing that creating the prop[ref] observable will not leak an observation record. var template = stache( @@ -125,11 +125,11 @@ QUnit.test("let multiple updates (#650)", function(){ data.set("ref", data.get("ref")+1 ); data.set("ref", data.get("ref")+1 ); - QUnit.ok(true, "got here"); + assert.ok(true, "got here"); }); -QUnit.test("let does not observe itself", function(){ +QUnit.test("let does not observe itself", function(assert) { //queues.stopAfterTaskCount(200); //queues.log("flush"); //queues.breakOnTaskName("Observation.onDependencyChange") @@ -169,6 +169,6 @@ QUnit.test("let does not observe itself", function(){ vm.set("delete", true); - QUnit.ok(true, "got here without breaking"); - QUnit.equal( frag.firstChild.querySelector("p").innerHTML, "You are deleting"); + assert.ok(true, "got here without breaking"); + assert.equal( frag.firstChild.querySelector("p").innerHTML, "You are deleting"); }); diff --git a/helpers/-portal-test.js b/helpers/-portal-test.js index ff239cda..1c366906 100644 --- a/helpers/-portal-test.js +++ b/helpers/-portal-test.js @@ -10,19 +10,19 @@ require("./-portal"); QUnit.module("can-stache #portal helper"); -test("basics", function(){ +QUnit.test("basics", function(assert) { var el = document.createElement("div"); var template = stache("{{#portal(root)}}hello {{name}}{{/portal}}"); var vm = new DefineMap({name: "Matthew", root: el}); template(vm); - equal(el.firstChild.nextSibling.nodeValue, "Matthew"); + assert.equal(el.firstChild.nextSibling.nodeValue, "Matthew"); vm.name ="Wilbur"; - equal(el.firstChild.nextSibling.nodeValue, "Wilbur"); + assert.equal(el.firstChild.nextSibling.nodeValue, "Wilbur"); }); -test("element is observable", function(){ +QUnit.test("element is observable", function(assert) { var el = document.createElement("div"); var template = stache("{{#portal(root)}}{{name}}{{/}}"); var vm = new DefineMap({name: "Matthew", root: null}); @@ -30,10 +30,10 @@ test("element is observable", function(){ template(vm); vm.root = el; - equal(el.firstChild.nodeValue, "Matthew"); + assert.equal(el.firstChild.nodeValue, "Matthew"); }); -test("element changes", function() { +QUnit.test("element changes", function(assert) { var one = document.createElement("div"); var two = document.createElement("div"); @@ -41,14 +41,14 @@ test("element changes", function() { var vm = new DefineMap({name: "Matthew", root: one}); template(vm); - equal(one.firstChild.nodeValue, "Matthew"); + assert.equal(one.firstChild.nodeValue, "Matthew"); vm.root = two; - equal(two.firstChild.nodeValue, "Matthew"); - equal(one.firstChild, null, "One had its children removed"); + assert.equal(two.firstChild.nodeValue, "Matthew"); + assert.equal(one.firstChild, null, "One had its children removed"); }); -test("tears down when the element is removed", function() { +QUnit.test("tears down when the element is removed", function(assert) { var doc = document.implementation.createHTMLDocument("test"); globals.setKeyValue("document", doc); @@ -59,18 +59,18 @@ test("tears down when the element is removed", function() { var vm = new DefineMap({name: "Matthew", root: el}); template(vm); - equal(el.firstChild.nodeValue, "Matthew"); + assert.equal(el.firstChild.nodeValue, "Matthew"); domMutate.onNodeRemoval(el, function() { - equal(el.firstChild, null, "removed when parent removed"); - start(); + assert.equal(el.firstChild, null, "removed when parent removed"); + done(); }); - stop(); + var done = assert.async(); domMutateNode.removeChild.call(doc.body, el); }); -test("conditionally rendering a portal", function() { +QUnit.test("conditionally rendering a portal", function(assert) { var one = document.createElement("div"); var two = document.createElement("span"); @@ -79,26 +79,26 @@ test("conditionally rendering a portal", function() { var vm = new DefineMap({page: "one", name: "Matthew", one: one, two: two}); template(vm); - equal(one.firstChild.nodeValue, "Matthew"); - equal(two.firstChild, null, "nothing rendered to two"); + assert.equal(one.firstChild.nodeValue, "Matthew"); + assert.equal(two.firstChild, null, "nothing rendered to two"); vm.page = "two"; - equal(one.firstChild, null, "nothing rendered to one"); - equal(two.firstChild.nodeValue, "Matthew"); + assert.equal(one.firstChild, null, "nothing rendered to one"); + assert.equal(two.firstChild.nodeValue, "Matthew"); }); -test("Doesn't mess with existing DOM", function() { +QUnit.test("Doesn't mess with existing DOM", function(assert) { var el = document.createElement("div"); el.appendChild(document.createTextNode("Hello")); var template = stache("{{#portal(root)}}{{name}}{{/portal}}"); var vm = new DefineMap({name: "Matthew", root: el}); template(vm); - equal(el.firstChild.nodeValue, "Hello", "existing content left alone"); - equal(el.firstChild.nextSibling.nodeValue, "Matthew"); + assert.equal(el.firstChild.nodeValue, "Hello", "existing content left alone"); + assert.equal(el.firstChild.nextSibling.nodeValue, "Matthew"); }); -test("Adds the done.keepNode symbol to nodes", function() { +QUnit.test("Adds the done.keepNode symbol to nodes", function(assert) { var el = document.createElement("div"); var template = stache("{{#portal(root)}}one
two
{{/portal}}"); var vm = new DefineMap({ root: el }); @@ -106,38 +106,38 @@ test("Adds the done.keepNode symbol to nodes", function() { var child = el.firstChild; do { - ok(child[canSymbol.for("done.keepNode")], "symbol added to this node"); + assert.ok(child[canSymbol.for("done.keepNode")], "symbol added to this node"); child = child.nextSibling; } while(child); }); -test("Doesn't do anything if there isn't a place to put the content", function() { +QUnit.test("Doesn't do anything if there isn't a place to put the content", function(assert) { var view = stache("{{#portal(root)}}two{{/portal}}"); var vm = new DefineMap({ root: null }); var frag = view(vm); - QUnit.equal(frag.firstChild.nodeType, 8, "Only rendered the comment node"); + assert.equal(frag.firstChild.nodeType, 8, "Only rendered the comment node"); }); -test("Dynamic content outside portal", function() { +QUnit.test("Dynamic content outside portal", function(assert) { var view = stache("{{#portal(root)}}two{{/portal}}
{{#if(showThing)}}one{{/if}}
"); var vm = new DefineMap({ showThing: false, root: null }); var frag = view(vm); var div = frag.firstChild.nextSibling; - QUnit.equal(div.firstChild.firstChild, null, "nothing rendered in the div yet"); + assert.equal(div.firstChild.firstChild, null, "nothing rendered in the div yet"); // Flip the conditional vm.showThing = true; - QUnit.equal(div.firstChild.firstChild.nodeValue, "one", "shows the template content"); + assert.equal(div.firstChild.firstChild.nodeValue, "one", "shows the template content"); // Set the element vm.root = div; - QUnit.equal(div.firstChild.nextSibling.firstChild.nodeValue, "two", "shows the portaled content"); + assert.equal(div.firstChild.nextSibling.firstChild.nodeValue, "two", "shows the portaled content"); }); -test("Works when DOM nodes are removed outside of stache", function() { +QUnit.test("Works when DOM nodes are removed outside of stache", function(assert) { var view = stache("{{#if(show)}}{{#portal(root)}} tests {{/portal}}{{/if}}"); var root = document.createElement("div"); var vm = new DefineMap({ root: root, show: true }); @@ -151,9 +151,9 @@ test("Works when DOM nodes are removed outside of stache", function() { try { vm.show = false; - QUnit.ok(true, "Did not throw"); + assert.ok(true, "Did not throw"); } catch(e) { - QUnit.ok(false, e); + assert.ok(false, e); } }); diff --git a/package.json b/package.json index ee671338..d39b4284 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "jshint": "^2.9.4", "steal": "^1.5.19", "steal-benchmark": "^0.0.1", - "steal-qunit": "^1.0.0", + "steal-qunit": "^2.0.0", "steal-tools": "^1.0.1", "testee": "^0.9.0" } diff --git a/test/expression-test.js b/test/expression-test.js index 7930795f..3f006eef 100644 --- a/test/expression-test.js +++ b/test/expression-test.js @@ -11,34 +11,34 @@ var testHelpers = require('can-test-helpers'); QUnit.module("can-stache/src/expression"); -QUnit.test("expression.tokenize", function(){ +QUnit.test("expression.tokenize", function(assert) { var literals = "'quote' \"QUOTE\" 1 undefined null true false 0.1"; var res = expression.tokenize(literals); - deepEqual(res, literals.split(" ")); + assert.deepEqual(res, literals.split(" ")); var keys = "key foo.bar foo@bar %foo *foo foo/bar"; res = expression.tokenize(keys); - deepEqual(res, keys.split(" ")); + assert.deepEqual(res, keys.split(" ")); var syntax = "( ) , ~ ="; res = expression.tokenize(syntax); - deepEqual(res, syntax.split(" ")); + assert.deepEqual(res, syntax.split(" ")); var curly = "{{ }}"; res = expression.tokenize(curly); - deepEqual(res, []); + assert.deepEqual(res, []); var bracket = "[foo] bar [baz]"; res = expression.tokenize(bracket); - deepEqual(res, ["[", "foo", "]", " ", "bar", " ", "[", "baz", "]", " "]); + assert.deepEqual(res, ["[", "foo", "]", " ", "bar", " ", "[", "baz", "]", " "]); }); -test("expression.ast - helper followed by hash", function(){ +QUnit.test("expression.ast - helper followed by hash", function(assert) { var ast = expression.ast("print_hash prop=own_prop"); - deepEqual(ast, { + assert.deepEqual(ast, { type: "Helper", method: { type: "Lookup", @@ -60,10 +60,10 @@ test("expression.ast - helper followed by hash", function(){ }); -test("expression.ast - root hash expressions work", function(){ +QUnit.test("expression.ast - root hash expressions work", function(assert) { var ast = expression.ast("prop=own_prop"); - deepEqual(ast, { + assert.deepEqual(ast, { type: "Hashes", children: [ { @@ -76,10 +76,10 @@ test("expression.ast - root hash expressions work", function(){ }); -test("expression.ast - nested call expressions", function(){ +QUnit.test("expression.ast - nested call expressions", function(assert) { var ast = expression.ast("foo()()"); - deepEqual(ast, { + assert.deepEqual(ast, { type: "Call", method: { type: "Call", @@ -89,7 +89,7 @@ test("expression.ast - nested call expressions", function(){ }); -test("expression.ast - everything", function(){ +QUnit.test("expression.ast - everything", function(assert) { var ast = expression.ast("helperA helperB(1, valueA, propA=~valueB propC=2, 1).zed() 'def' nested@prop outerPropA=helperC(2,valueB)"); var helperBCall = { @@ -125,7 +125,7 @@ test("expression.ast - everything", function(){ ] }; - deepEqual(ast, { + assert.deepEqual(ast, { type: "Helper", method: { type: "Lookup", @@ -156,7 +156,7 @@ test("expression.ast - everything", function(){ }); }); -test("expression.parse - everything", function(){ +QUnit.test("expression.parse - everything", function(assert) { var exprData = expression.parse("helperA helperB(1, valueA, propA=~valueB propC=2, 1).zed 'def' nested.prop() outerPropA=helperC(2,valueB)"); @@ -203,22 +203,22 @@ test("expression.parse - everything", function(){ } ); - deepEqual(callHelperB, exprData.argExprs[0].rootExpr, "call helper b"); + assert.deepEqual(callHelperB, exprData.argExprs[0].rootExpr, "call helper b"); - deepEqual(callHelperC, exprData.hashExprs.outerPropA, "helperC call"); + assert.deepEqual(callHelperC, exprData.hashExprs.outerPropA, "helperC call"); - deepEqual(callHelperBdotZed, exprData.argExprs[0], "call helper b.zed"); + assert.deepEqual(callHelperBdotZed, exprData.argExprs[0], "call helper b.zed"); var expectedArgs = [callHelperBdotZed, def, callNestedProp]; canReflect.each(exprData.argExprs, function(arg, i){ - deepEqual(arg, expectedArgs[i], "helperA arg["+i+"]"); + assert.deepEqual(arg, expectedArgs[i], "helperA arg["+i+"]"); }); - deepEqual(exprData, callHelperA, "full thing"); + assert.deepEqual(exprData, callHelperA, "full thing"); }); -test("expression.parse(str, {lookupRule: 'method', methodRule: 'call'})", - function(){ +QUnit.test("expression.parse(str, {lookupRule: 'method', methodRule: 'call'})", + function(assert) { var exprData = expression.parse("withArgs content=content", { lookupRule: "method", @@ -230,14 +230,14 @@ test("expression.parse(str, {lookupRule: 'method', methodRule: 'call'})", content: valueContent })); - equal(exprData.argExprs.length, 1, "there is one arg"); - deepEqual(exprData.argExprs[0], hashArg, "correct hashes"); + assert.equal(exprData.argExprs.length, 1, "there is one arg"); + assert.deepEqual(exprData.argExprs[0], hashArg, "correct hashes"); }); -test("expression.parse nested Call expressions", function(){ +QUnit.test("expression.parse nested Call expressions", function(assert) { QUnit.expect(7); - deepEqual(expression.parse("foo()()"), + assert.deepEqual(expression.parse("foo()()"), new expression.Call( new expression.Call( new expression.Lookup('@foo'), @@ -263,10 +263,10 @@ test("expression.parse nested Call expressions", function(){ new Scope( new SimpleMap({ bar: function(outter) { - equal(outter, 1, "Outter called with correct value"); + assert.equal(outter, 1, "Outter called with correct value"); return function (inner) { - equal(inner, 2, "Inner called with correct value"); + assert.equal(inner, 2, "Inner called with correct value"); return 'Inner!'; }; @@ -274,7 +274,7 @@ test("expression.parse nested Call expressions", function(){ }) ) ); - equal(compute.get(), "Inner!", "Got the inner value"); + assert.equal(compute.get(), "Inner!", "Got the inner value"); expr = new expression.Call( new expression.Call( @@ -289,10 +289,10 @@ test("expression.parse nested Call expressions", function(){ new Scope( new SimpleMap({ foobar: function(outter) { - equal(outter, 'Matt', "Outter called with correct value"); + assert.equal(outter, 'Matt', "Outter called with correct value"); return function (inner) { - equal(inner, 'Chaffe', "Inner called with correct value"); + assert.equal(inner, 'Chaffe', "Inner called with correct value"); return 'Inner!'; }; @@ -302,18 +302,18 @@ test("expression.parse nested Call expressions", function(){ }) ) ); - equal(compute.get(), "Inner!", "Got the inner value"); + assert.equal(compute.get(), "Inner!", "Got the inner value"); }); -test("numeric expression.Literal", function(){ +QUnit.test("numeric expression.Literal", function(assert) { var exprData = expression.parse("3"); var result = new expression.Literal(3); - deepEqual( exprData, result); + assert.deepEqual( exprData, result); }); -test("expression.Helper:value non-observable values", function(){ +QUnit.test("expression.Helper:value non-observable values", function(assert) { // {{fullName 'marshall' 'thompson'}} var scope = new Scope({ @@ -330,14 +330,14 @@ test("expression.Helper:value non-observable values", function(){ var result = callFullName.value(scope, new Scope({}), {}); - equal(expression.toComputeOrValue(result)(), "marshall thompson"); + assert.equal(expression.toComputeOrValue(result)(), "marshall thompson"); }); -test("expression.Helper:value observable values", function(){ +QUnit.test("expression.Helper:value observable values", function(assert) { // {{fullName first 'thompson'}} var obj = { fullName: function(first, last){ - QUnit.equal(this, obj, "this is right"); + assert.equal(this, obj, "this is right"); return first()+" "+last; }, first: new SimpleObservable("marshall") @@ -352,10 +352,10 @@ test("expression.Helper:value observable values", function(){ var result = callFullName.value(scope, new Scope({}) ); - equal(result(), "marshall thompson"); + assert.equal(result(), "marshall thompson"); }); -test("methods can return values (#1887)", function(){ +QUnit.test("methods can return values (#1887)", function(assert) { var MyMap = SimpleMap.extend({ getSomething: function(arg){ return this.attr("foo") + arg(); @@ -373,10 +373,10 @@ test("methods can return values (#1887)", function(){ var result = callGetSomething.value(scope, new Scope({}), {asCompute: true}); - equal(result(), 5); + assert.equal(result(), 5); }); -test("methods don't update correctly (#1891)", function(){ +QUnit.test("methods don't update correctly (#1891)", function(assert) { var map = new SimpleMap({ num: 1 }); @@ -400,11 +400,11 @@ test("methods don't update correctly (#1891)", function(){ map.runTest(); var func = canReflect.getValue( num2 ); - equal( func() , 4, "num2 updated correctly"); + assert.equal( func() , 4, "num2 updated correctly"); }); -test("call expressions called with different scopes give different results (#1791)", function(){ +QUnit.test("call expressions called with different scopes give different results (#1791)", function(assert) { var exprData = expression.parse("doSomething(number)"); var res = exprData.value(new Scope({ @@ -414,7 +414,7 @@ test("call expressions called with different scopes give different results (#179 number: new SimpleObservable(2) })); - equal( res.get(), 4); + assert.equal( res.get(), 4); res = exprData.value(new Scope({ doSomething: function(num){ @@ -423,10 +423,10 @@ test("call expressions called with different scopes give different results (#179 number: new SimpleObservable(4) })); - equal( res.get(), 12); + assert.equal( res.get(), 12); }); -test("call expressions called with different contexts (#616)", 1, function(){ +QUnit.test("call expressions called with different contexts (#616)", 1, function(assert) { var exprData = expression.parse("this.foo.doSomething()"); var doSomething = function(){ return this.value; @@ -442,7 +442,7 @@ test("call expressions called with different contexts (#616)", 1, function(){ canReflect.onValue(res, function(value){ - QUnit.equal(value, "B"); + assert.equal(value, "B"); }); context.set("foo",{ @@ -451,53 +451,53 @@ test("call expressions called with different contexts (#616)", 1, function(){ }); }); -test("convertKeyToLookup", function(){ +QUnit.test("convertKeyToLookup", function(assert) { - equal( expression.convertKeyToLookup("../foo"), "../@foo" ); - equal( expression.convertKeyToLookup("foo"), "@foo" ); - equal( expression.convertKeyToLookup(".foo"), "@foo" ); - equal( expression.convertKeyToLookup("./foo"), "./@foo" ); - equal( expression.convertKeyToLookup("foo.bar"), "foo@bar" ); + assert.equal( expression.convertKeyToLookup("../foo"), "../@foo" ); + assert.equal( expression.convertKeyToLookup("foo"), "@foo" ); + assert.equal( expression.convertKeyToLookup(".foo"), "@foo" ); + assert.equal( expression.convertKeyToLookup("./foo"), "./@foo" ); + assert.equal( expression.convertKeyToLookup("foo.bar"), "foo@bar" ); }); -test("expression.ast - [] operator", function(){ - deepEqual(expression.ast("['propName']"), { +QUnit.test("expression.ast - [] operator", function(assert) { + assert.deepEqual(expression.ast("['propName']"), { type: "Bracket", children: [{type: "Literal", value: "propName"}] }, "['propName'] valid"); - deepEqual(expression.ast("[propName]"), { + assert.deepEqual(expression.ast("[propName]"), { type: "Bracket", children: [{type: "Lookup", key: "propName"}] }, "[propName] valid"); - deepEqual(expression.ast("foo['bar']"), { + assert.deepEqual(expression.ast("foo['bar']"), { type: "Bracket", root: {type: "Lookup", key: "foo"}, children: [{type: "Literal", value: "bar"}] }, "foo['bar'] valid"); - deepEqual(expression.ast("foo[bar]"), { + assert.deepEqual(expression.ast("foo[bar]"), { type: "Bracket", root: {type: "Lookup", key: "foo"}, children: [{type: "Lookup", key: "bar"}] }, "foo[bar] valid"); - deepEqual(expression.ast("foo[bar()]"), { + assert.deepEqual(expression.ast("foo[bar()]"), { type: "Bracket", root: {type: "Lookup", key: "foo"}, children: [{type: "Call", method: {key: "@bar", type: "Lookup" }}] }, "foo[bar()] valid"); - deepEqual(expression.ast("foo()[bar]"), { + assert.deepEqual(expression.ast("foo()[bar]"), { type: "Bracket", root: {type: "Call", method: {key: "@foo", type: "Lookup" } }, children: [{type: "Lookup", key: "bar"}] }, "foo()[bar] valid"); - deepEqual(expression.ast("foo [bar]"), { + assert.deepEqual(expression.ast("foo [bar]"), { type: "Helper", method: { type: "Lookup", @@ -509,7 +509,7 @@ test("expression.ast - [] operator", function(){ }] }, "foo [bar] valid"); - deepEqual(expression.ast("eq foo['bar'] 'foo'"), { + assert.deepEqual(expression.ast("eq foo['bar'] 'foo'"), { type: "Helper", method: { type: "Lookup", @@ -528,7 +528,7 @@ test("expression.ast - [] operator", function(){ "eq foo['bar'] 'foo' valid" ); - deepEqual(expression.ast("eq foo[bar] foo"), { + assert.deepEqual(expression.ast("eq foo[bar] foo"), { type: "Helper", method: { type: "Lookup", @@ -545,7 +545,7 @@ test("expression.ast - [] operator", function(){ }] }, "eq foo[bar] foo valid"); - deepEqual(expression.ast("foo[bar][baz]"), { + assert.deepEqual(expression.ast("foo[bar][baz]"), { type: "Bracket", root: { type: "Bracket", @@ -555,7 +555,7 @@ test("expression.ast - [] operator", function(){ children: [{type: "Lookup", key: "baz"}] }, "foo[bar][baz] valid"); - deepEqual(expression.ast("foo[bar].baz"), { + assert.deepEqual(expression.ast("foo[bar].baz"), { type: "Lookup", key: "baz", root: { @@ -565,7 +565,7 @@ test("expression.ast - [] operator", function(){ } }, "foo[bar].baz"); - deepEqual(expression.ast("eq foo[bar].baz xyz"), { + assert.deepEqual(expression.ast("eq foo[bar].baz xyz"), { type: "Helper", method: { type: "Lookup", @@ -587,22 +587,22 @@ test("expression.ast - [] operator", function(){ }, "eq foo[bar].baz xyz"); }); -test("expression.parse - [] operator", function(){ - deepEqual(expression.parse("['propName']"), +QUnit.test("expression.parse - [] operator", function(assert) { + assert.deepEqual(expression.parse("['propName']"), new expression.Bracket( new expression.Literal('propName') ), "['propName']" ); - deepEqual(expression.parse("[propName]"), + assert.deepEqual(expression.parse("[propName]"), new expression.Bracket( new expression.Lookup('propName') ), "[propName]" ); - deepEqual(expression.parse("foo['bar']"), + assert.deepEqual(expression.parse("foo['bar']"), new expression.Bracket( new expression.Literal('bar'), new expression.Lookup('foo'), @@ -611,7 +611,7 @@ test("expression.parse - [] operator", function(){ "foo['bar']" ); - deepEqual(expression.parse("foo[bar]"), + assert.deepEqual(expression.parse("foo[bar]"), new expression.Bracket( new expression.Lookup('bar'), new expression.Lookup('foo'), @@ -620,7 +620,7 @@ test("expression.parse - [] operator", function(){ "foo[bar]" ); - deepEqual(expression.parse("foo()[bar]"), + assert.deepEqual(expression.parse("foo()[bar]"), new expression.Bracket( new expression.Lookup('bar'), new expression.Call( @@ -633,7 +633,7 @@ test("expression.parse - [] operator", function(){ ); var exprData = expression.parse("foo[bar()]"); - deepEqual(exprData, + assert.deepEqual(exprData, new expression.Bracket( new expression.Call( new expression.Lookup('@bar'), @@ -646,7 +646,7 @@ test("expression.parse - [] operator", function(){ ); exprData = expression.parse("foo()[bar()]"); - deepEqual(exprData, + assert.deepEqual(exprData, new expression.Bracket( new expression.Call( new expression.Lookup("@bar"), @@ -662,8 +662,8 @@ test("expression.parse - [] operator", function(){ ); exprData = expression.parse("equal(foo(), [bar])"); - equal(exprData.argExprs.length, 2, "there are two arguments"); - deepEqual(exprData, + assert.equal(exprData.argExprs.length, 2, "there are two arguments"); + assert.deepEqual(exprData, new expression.Call( new expression.Lookup("@equal"), [ @@ -679,7 +679,7 @@ test("expression.parse - [] operator", function(){ ); }); -test("Bracket expression", function(){ +QUnit.test("Bracket expression", function(assert) { // ["bar"] var expr = new expression.Bracket( new expression.Literal("bar") @@ -689,7 +689,7 @@ test("Bracket expression", function(){ new SimpleMap({bar: "name"}) ) ); - equal(compute.get(), "name"); + assert.equal(compute.get(), "name"); // [bar] expr = new expression.Bracket( @@ -700,7 +700,7 @@ test("Bracket expression", function(){ new SimpleMap({bar: "name", name: "Kevin"}) ) ); - equal(compute.get(), "Kevin"); + assert.equal(compute.get(), "Kevin"); // foo["bar"] expr = new expression.Bracket( @@ -712,7 +712,7 @@ test("Bracket expression", function(){ new SimpleMap({foo: {bar: "name"}}) ) ); - equal(compute.get(), "name"); + assert.equal(compute.get(), "name"); // foo["bar.baz"] expr = new expression.Bracket( @@ -724,7 +724,7 @@ test("Bracket expression", function(){ new SimpleMap({foo: {"bar.baz": "name"}}) ) ); - equal(compute.get(), "name",'foo["bar.baz"]'); + assert.equal(compute.get(), "name",'foo["bar.baz"]'); // foo["bar.baz.quz"] expr = new expression.Bracket( @@ -736,7 +736,7 @@ test("Bracket expression", function(){ new SimpleMap({foo: {"bar.baz.quz": "name"}}) ) ); - equal(compute.get(), "name",'foo["bar.baz.quz"]'); + assert.equal(compute.get(), "name",'foo["bar.baz.quz"]'); // foo[bar] expr = new expression.Bracket( @@ -749,10 +749,10 @@ test("Bracket expression", function(){ state ) ); - equal(compute.get(), "Kevin", "foo[bar] get"); + assert.equal(compute.get(), "Kevin", "foo[bar] get"); compute.set("Curtis"); - equal(state.get("foo").get("name"), "Curtis"); + assert.equal(state.get("foo").get("name"), "Curtis"); // foo()[bar] expr = new expression.Bracket( @@ -768,7 +768,7 @@ test("Bracket expression", function(){ new SimpleMap({foo: function() { return {name: "Kevin"}; }, bar: "name"}) ) ); - equal(compute.get(), "Kevin"); + assert.equal(compute.get(), "Kevin"); // foo[bar()] expr = new expression.Bracket( @@ -787,7 +787,7 @@ test("Bracket expression", function(){ }) ) ); - equal(compute.get(), "Kevin"); + assert.equal(compute.get(), "Kevin"); // foo()[bar()] expr = new expression.Bracket( @@ -810,7 +810,7 @@ test("Bracket expression", function(){ }) ) ); - equal(compute.get(), "Kevin"); + assert.equal(compute.get(), "Kevin"); // foo([bar]) expr = new expression.Call( @@ -831,10 +831,10 @@ test("Bracket expression", function(){ }) ) ); - equal(compute.get(), "Kevin!"); + assert.equal(compute.get(), "Kevin!"); }); -QUnit.test("registerConverter helpers push and pull correct values", function () { +QUnit.test("registerConverter helpers push and pull correct values", function(assert) { helpers.registerConverter('numberToHex', { get: function(valCompute) { @@ -856,14 +856,14 @@ QUnit.test("registerConverter helpers push and pull correct values", function () //var renderer = stache(''); - equal(twoWayCompute.get(), 'ff', 'Converter called'); + assert.equal(twoWayCompute.get(), 'ff', 'Converter called'); twoWayCompute.set('7f'); - equal(data.get("observeVal"), 127, 'push converter called'); + assert.equal(data.get("observeVal"), 127, 'push converter called'); }); -QUnit.test("registerConverter helpers push and pull multiple values", function () { +QUnit.test("registerConverter helpers push and pull multiple values", function(assert) { helpers.registerConverter('isInList', { get: function(valCompute, list) { @@ -887,12 +887,12 @@ QUnit.test("registerConverter helpers push and pull multiple values", function ( //var renderer = stache(''); - equal(twoWayCompute.get(), false, 'Converter called'); + assert.equal(twoWayCompute.get(), false, 'Converter called'); twoWayCompute.set(5); - deepEqual(data.attr("list").attr(), [1,2,3,5], 'push converter called'); + assert.deepEqual(data.attr("list").attr(), [1,2,3,5], 'push converter called'); }); -QUnit.test("registerConverter helpers are chainable", function () { +QUnit.test("registerConverter helpers are chainable", function(assert) { helpers.registerConverter('numberToHex', { get: function(valCompute) { @@ -923,16 +923,16 @@ QUnit.test("registerConverter helpers are chainable", function () { //var renderer = stache(''); - equal(twoWayCompute.get(), 'FF', 'Converter called'); + assert.equal(twoWayCompute.get(), 'FF', 'Converter called'); twoWayCompute.set('7F'); - equal(data.attr("observeVal"), 127, 'push converter called'); + assert.equal(data.attr("observeVal"), 127, 'push converter called'); }); -test('foo().bar', function() { +QUnit.test('foo().bar', function(assert) { // expression.ast var ast4 = expression.ast("foo().bar"); - deepEqual(ast4, { + assert.deepEqual(ast4, { type: "Lookup", key: "bar", root: {type: "Call", method: {key: "@foo", type: "Lookup" } } @@ -940,7 +940,7 @@ test('foo().bar', function() { // expression.parse var exprData = expression.parse("foo().bar"); - deepEqual(exprData, + assert.deepEqual(exprData, new expression.Lookup( "bar", new expression.Call( new expression.Lookup("@foo"), [], {} ) @@ -957,10 +957,10 @@ test('foo().bar', function() { new SimpleMap({foo: function() { return {bar: "Kevin"}; }}) ) ); - equal(compute.get(), "Kevin"); + assert.equal(compute.get(), "Kevin"); }); -test("Helper with a ~ key operator (#112)", function() { +QUnit.test("Helper with a ~ key operator (#112)", function(assert) { var ast = expression.ast('each ~foo'); var expected = { @@ -969,11 +969,11 @@ test("Helper with a ~ key operator (#112)", function() { children: [{type: "Arg", key: "~", children: [{type: "Lookup", key: "foo"} ]}] }; - QUnit.deepEqual(ast, expected); + assert.deepEqual(ast, expected); }); -test("ast with [double][brackets] or [bracket].prop (#207)", function(){ +QUnit.test("ast with [double][brackets] or [bracket].prop (#207)", function(assert) { var ast = expression.ast("test['foo'][0]"); @@ -987,7 +987,7 @@ test("ast with [double][brackets] or [bracket].prop (#207)", function(){ } }; - QUnit.deepEqual(ast, expected); + assert.deepEqual(ast, expected); ast = expression.ast("test['foo'].zed"); @@ -1002,7 +1002,7 @@ test("ast with [double][brackets] or [bracket].prop (#207)", function(){ }; - QUnit.deepEqual(ast, expected); + assert.deepEqual(ast, expected); ast = expression.ast("test['foo'].zed['bar']"); @@ -1021,25 +1021,25 @@ test("ast with [double][brackets] or [bracket].prop (#207)", function(){ }; - QUnit.deepEqual(ast, expected); + assert.deepEqual(ast, expected); }); -testHelpers.dev.devOnlyTest("All expression types have sourceText on prototype", function(){ +testHelpers.dev.devOnlyTest("All expression types have sourceText on prototype", function (assert){ ["Arg", "Bracket", "Call", "Hashes", "Helper", "Literal"].forEach(function(name){ - QUnit.ok(typeof expression[name].prototype.sourceText === "function", name); + assert.ok(typeof expression[name].prototype.sourceText === "function", name); }); }); -testHelpers.dev.devOnlyTest("expression.sourceText - everything", function(){ +testHelpers.dev.devOnlyTest("expression.sourceText - everything", function (assert){ var source = "helperA helperB(1,valueA,propA=~valueB propC=2,1).zed \"def\" nested.prop() outerPropA=helperC(2,valueB)"; var exprData = expression.parse(source); - QUnit.equal(exprData.sourceText(),source); + assert.equal(exprData.sourceText(),source); }); -test('Call Expressions can return functions instead of Observations', function() { +QUnit.test('Call Expressions can return functions instead of Observations', function(assert) { var data = new SimpleMap({ name: "kevin", foo: function() { @@ -1053,11 +1053,11 @@ test('Call Expressions can return functions instead of Observations', function() expr.value( new Scope( data ) ) ); - equal(canReflect.getValue(val.value), "kevin", "got correct initial value"); + assert.equal(canReflect.getValue(val.value), "kevin", "got correct initial value"); - ok(canReflect.isObservableLike(val.value), "value is observable by default"); + assert.ok(canReflect.isObservableLike(val.value), "value is observable by default"); canReflect.onValue(val.value, function(newVal) { - equal(newVal, "mark", "got correct changed value"); + assert.equal(newVal, "mark", "got correct changed value"); }); data.set("name", "mark"); @@ -1068,8 +1068,8 @@ test('Call Expressions can return functions instead of Observations', function() }) ); - equal(canReflect.getValue(nonBindingVal.value), "mark", "got correct initial value"); - ok(!canReflect.isObservableLike(nonBindingVal.value), "value is not observable when doNotWrapInObservation is true"); + assert.equal(canReflect.getValue(nonBindingVal.value), "mark", "got correct initial value"); + assert.ok(!canReflect.isObservableLike(nonBindingVal.value), "value is not observable when doNotWrapInObservation is true"); }); QUnit.test("negative literals ast", function(assert) { @@ -1086,7 +1086,7 @@ QUnit.test("negative literals ast", function(assert) { -testHelpers.dev.devOnlyTest("don't warn on perfectly fine function result reads", function () { +testHelpers.dev.devOnlyTest("don't warn on perfectly fine function result reads", function (assert) { var teardown = testHelpers.dev.willWarn(/Unable to find key/); var exprData = expression.parse("method().toFixed(1)",{baseMethodType: "Call"}); @@ -1098,19 +1098,19 @@ testHelpers.dev.devOnlyTest("don't warn on perfectly fine function result reads" }); var result = exprData.value(scope); - QUnit.equal( result.get(), "1.1" , "got value"); + assert.equal( result.get(), "1.1" , "got value"); - QUnit.equal(teardown(), 0, 'got expected warning'); + assert.equal(teardown(), 0, 'got expected warning'); }); -test("let foo=bar,zed=ted", function(){ +QUnit.test("let foo=bar,zed=ted", function(assert) { //var helperAst = expression.ast("let foo=bar zed=ted"); var commaHelperAst = expression.ast("let foo=bar,zed=ted"); - //QUnit.deepEqual( commaHelperAst, helperAst, "commas work in helpers"); + //assert.deepEqual( commaHelperAst, helperAst, "commas work in helpers"); - QUnit.deepEqual(commaHelperAst, { + assert.deepEqual(commaHelperAst, { "type": "Helper", "method": { "type": "Lookup", "key": "let" }, "children": [ @@ -1134,7 +1134,7 @@ test("let foo=bar,zed=ted", function(){ }); -test("double [] in a function", function(){ +QUnit.test("double [] in a function", function(assert) { var ast = expression.ast("log(thing['prop'][0])"); var logAst = { @@ -1155,5 +1155,5 @@ test("double [] in a function", function(){ } ] }; - QUnit.deepEqual(ast, logAst); + assert.deepEqual(ast, logAst); }); diff --git a/test/filename-test.js b/test/filename-test.js index 21d0f408..9efbd0ce 100644 --- a/test/filename-test.js +++ b/test/filename-test.js @@ -4,42 +4,42 @@ var DefineMap = require("can-define/map/map"); QUnit.module("can-stache: filename"); -testHelpers.dev.devOnlyTest("warn on missmatched tag (canjs/canjs#1476)", function() { +testHelpers.dev.devOnlyTest("warn on missmatched tag (canjs/canjs#1476)", function (assert) { var teardown = testHelpers.dev.willWarn("filename.stache:3: unexpected closing tag {{/foo}} expected {{/if}}"); stache("filename.stache", "{{#if someCondition}}\n...\n{{/foo}}"); - QUnit.equal(teardown(), 1, "{{#if someCondition}}"); + assert.equal(teardown(), 1, "{{#if someCondition}}"); teardown = testHelpers.dev.willWarn("filename.stache:3: unexpected closing tag {{/foo}} expected {{/if}}"); stache("filename.stache", "{{^if someCondition}}\n...\n{{/foo}}"); - QUnit.equal(teardown(), 1, "{{^if someCondition}}"); + assert.equal(teardown(), 1, "{{^if someCondition}}"); teardown = testHelpers.dev.willWarn("filename.stache:3: unexpected closing tag {{/foo}} expected {{/call}}"); stache("filename.stache", "{{#call()}}\n...\n{{/foo}}"); - QUnit.equal(teardown(), 1, "{{#call()}}"); + assert.equal(teardown(), 1, "{{#call()}}"); teardown = testHelpers.dev.willWarn(/filename.stache/); stache("filename.stache", "{{#if}}...{{/}}"); stache("filename.stache", "{{#if someCondition}}...{{/if}}"); stache("filename.stache", "{{^if someCondition}}...{{/if}}"); stache("filename.stache", "{{#call()}}...{{/call}}"); - QUnit.equal(teardown(), 0, "matching tags should not have warnings"); + assert.equal(teardown(), 0, "matching tags should not have warnings"); }); -testHelpers.dev.devOnlyTest("work in a text section (#628)", function() { +testHelpers.dev.devOnlyTest("work in a text section (#628)", function (assert) { var teardown = testHelpers.dev.willWarn(/filename.stache:1: Unable to find key/); stache("filename.stache", "
")(); - QUnit.equal(teardown(), 1, "{{#if someCondition}}"); + assert.equal(teardown(), 1, "{{#if someCondition}}"); }); -testHelpers.dev.devOnlyTest("scope has filename", function(){ +testHelpers.dev.devOnlyTest("scope has filename", function (assert){ var template = stache('some-file', '{{scope.filename}}'); var frag = template(); - equal(frag.firstChild.nodeValue, 'some-file'); + assert.equal(frag.firstChild.nodeValue, 'some-file'); }); -testHelpers.dev.devOnlyTest("scope has correct filename after calling a partial", function(){ +testHelpers.dev.devOnlyTest("scope has correct filename after calling a partial", function (assert){ var innerTemplate = stache('some-partial', '{{scope.filename}}'); var outerTemplate = stache('some-file', '{{#if foo}}{{scope.filename}}{{/if}}{{>somePartial}}'); var vm = new DefineMap(); @@ -50,6 +50,6 @@ testHelpers.dev.devOnlyTest("scope has correct filename after calling a partial" }); vm.set('foo', 'bar'); - equal(frag.firstChild.nodeValue, 'some-file'); - equal(frag.firstChild.nextSibling.firstChild.nodeValue, 'some-partial'); + assert.equal(frag.firstChild.nodeValue, 'some-file'); + assert.equal(frag.firstChild.nextSibling.firstChild.nodeValue, 'some-partial'); }); diff --git a/test/nodelist-test.js b/test/nodelist-test.js index e150a3a5..976fd41c 100644 --- a/test/nodelist-test.js +++ b/test/nodelist-test.js @@ -3,7 +3,7 @@ var SimpleMap = require('can-simple-map'); var stache = require('can-stache'); QUnit.module("can-stache nodeList"); -QUnit.test("nodeList not cleaned (#486)", function(){ +QUnit.test("nodeList not cleaned (#486)", function(assert) { var template = stache("
"+ "{{#showHome}}"+ "

home

"+ @@ -24,5 +24,5 @@ QUnit.test("nodeList not cleaned (#486)", function(){ state.set("showHome", true); state.set("startsFalse", true); - QUnit.ok(true,"no errors at this point"); + assert.ok(true,"no errors at this point"); }); diff --git a/test/partials-test.js b/test/partials-test.js index 3a32cbb3..35c0ffa2 100644 --- a/test/partials-test.js +++ b/test/partials-test.js @@ -11,7 +11,7 @@ var canSymbol = require("can-symbol"); QUnit.module("can-stache partials"); -QUnit.test("Deeply nested partials", function () { +QUnit.test("Deeply nested partials", function(assert) { var t = { template: "{{#nest1}}{{#nest2}}{{>partial}}{{/nest2}}{{/nest1}}", expected: "Hello!", @@ -29,10 +29,10 @@ QUnit.test("Deeply nested partials", function () { } }; - QUnit.deepEqual(stacheTestHelpers.getText(t.template,t.data, {partials: t.partials}), t.expected); + assert.deepEqual(stacheTestHelpers.getText(t.template,t.data, {partials: t.partials}), t.expected); }); -QUnit.test("Partials correctly set context", function () { +QUnit.test("Partials correctly set context", function(assert) { var t = { template: "{{#users}}{{>partial}}{{/users}}", expected: "foo - bar", @@ -47,24 +47,24 @@ QUnit.test("Partials correctly set context", function () { } }; - QUnit.deepEqual(stacheTestHelpers.getText(t.template,t.data, {partials: t.partials}), t.expected); + assert.deepEqual(stacheTestHelpers.getText(t.template,t.data, {partials: t.partials}), t.expected); }); -test("Using a renderer function as a partial", function(){ +QUnit.test("Using a renderer function as a partial", function(assert) { var template = stache("{{> other}}"); var partial = stache("hello there"); var map = new SimpleMap({ other: null }); var frag = template(map); - equal(frag.firstChild.nodeValue, "", "Initially it is a blank textnode"); + assert.equal(frag.firstChild.nodeValue, "", "Initially it is a blank textnode"); map.set("other", partial); - equal(frag.firstChild.nodeValue, "hello there", "partial rendered"); + assert.equal(frag.firstChild.nodeValue, "hello there", "partial rendered"); }); -test("partials are not working within an {{#each}} (#2174)", function() { +QUnit.test("partials are not working within an {{#each}} (#2174)", function(assert) { var data = new SimpleMap({ items : new DefineList([{ @@ -79,23 +79,23 @@ test("partials are not working within an {{#each}} (#2174)", function() { data.get('items').get(0).set('name', 'WORLD'); - equal( frag.firstChild.innerHTML, "WORLD", "updated to world"); + assert.equal( frag.firstChild.innerHTML, "WORLD", "updated to world"); data.get('items').splice(0, 0, { name : 'HELLO' }); - equal( frag.firstChild.innerHTML, "HELLOWORLD"); + assert.equal( frag.firstChild.innerHTML, "HELLOWORLD"); }); -test("partials don't leak (#2174)", function() { +QUnit.test("partials don't leak (#2174)", function(assert) { stache.registerHelper("somethingCrazy", function(name, options){ return function(el){ var nodeList = [el]; nodeList.expression = "something crazy"; nodeLists.register(nodeList, function(){ - ok(true, "nodeList torn down"); + assert.ok(true, "nodeList torn down"); }, options.nodeList, true); nodeLists.update(options.nodeList, [el]); }; @@ -114,7 +114,7 @@ test("partials don't leak (#2174)", function() { data.get('items').pop(); }); -test("partials should leave binding to helpers and properties (#2174)", function() { +QUnit.test("partials should leave binding to helpers and properties (#2174)", function(assert) { stache.registerPartial('test', ' {{name}}'); var renderer = stache('{{#each items}}{{>test}}{{/each}}'); @@ -127,10 +127,10 @@ test("partials should leave binding to helpers and properties (#2174)", function // re-render the partial for the 0th element data.set('items.0.name', 'dave'); - equal(frag.firstChild.nextSibling.getAttribute('value'), 'user text'); + assert.equal(frag.firstChild.nextSibling.getAttribute('value'), 'user text'); }); -test("content within {{#if}} inside partial surrounded by {{#if}} should not display outside partial (#2186)", function() { +QUnit.test("content within {{#if}} inside partial surrounded by {{#if}} should not display outside partial (#2186)", function(assert) { stache.registerPartial('partial', '{{#showHiddenSection}}
Hidden
{{/showHiddenSection}}'); var renderer = stache('
{{#showPartial}}{{>partial}}{{/showPartial}}
'); var data = new SimpleMap({ @@ -141,27 +141,27 @@ test("content within {{#if}} inside partial surrounded by {{#if}} should not dis data.set('showHiddenSection', true); data.set('showPartial', false); - equal( frag.firstChild.innerHTML, ''); + assert.equal( frag.firstChild.innerHTML, ''); }); -test( "named partials don't render (canjs/can-stache/issues/3)", function () { +QUnit.test( "named partials don't render (canjs/can-stache/issues/3)", function(assert) { var renderer = stache( "{{
" ); var data = new SimpleMap( {} ); var frag = renderer( data ); - equal( stacheTestHelpers.innerHTML( frag.firstChild ), "" ); + assert.equal( stacheTestHelpers.innerHTML( frag.firstChild ), "" ); }); -test( "named partials can be inserted (canjs/can-stache/issues/3)", function () { +QUnit.test( "named partials can be inserted (canjs/can-stache/issues/3)", function(assert) { var renderer = stache( "{{Test:
{{>foo}}
" ); var data = new SimpleMap( {} ); var frag = renderer( data ); - equal( stacheTestHelpers.innerHTML( frag.lastChild ), "bar" ); + assert.equal( stacheTestHelpers.innerHTML( frag.lastChild ), "bar" ); }); -test( "named partials can be inserted with an initial scope (canjs/can-stache/issues/3)", function () { +QUnit.test( "named partials can be inserted with an initial scope (canjs/can-stache/issues/3)", function(assert) { var renderer = stache( "{{Test:
{{>personPartial person}}
" ); var data = new SimpleMap({ person: { @@ -171,10 +171,10 @@ test( "named partials can be inserted with an initial scope (canjs/can-stache/is }); var frag = renderer( data ); - equal( stacheTestHelpers.innerHTML( frag.lastChild ), "Anka, Darryl" ); + assert.equal( stacheTestHelpers.innerHTML( frag.lastChild ), "Anka, Darryl" ); }); -test( "named partials work with live binding (canjs/can-stache/issues/3)", function () { +QUnit.test( "named partials work with live binding (canjs/can-stache/issues/3)", function(assert) { var renderer = stache( "{{Test: {{nested.prop.test}}{{#each greatJoy}}
{{>foo}}
{{/each}}" ); var data = new SimpleMap({ nested: new SimpleMap({ @@ -192,20 +192,20 @@ test( "named partials work with live binding (canjs/can-stache/issues/3)", funct var div = document.createElement( "div" ); div.appendChild( frag ); - equal( stacheTestHelpers.innerHTML( div.getElementsByTagName( "span" )[ 0 ] ), "Test: works?", "Named partial property rendered" ); - equal( div.getElementsByTagName( "div" ).length, 3, "Named partial list rendered"); + assert.equal( stacheTestHelpers.innerHTML( div.getElementsByTagName( "span" )[ 0 ] ), "Test: works?", "Named partial property rendered" ); + assert.equal( div.getElementsByTagName( "div" ).length, 3, "Named partial list rendered"); data.get( "nested").get("prop").set("test", "works!" ); - equal( stacheTestHelpers.innerHTML( div.getElementsByTagName( "span" )[ 0 ] ), "Test: works!", "Named partial updates when attr is updated" ); + assert.equal( stacheTestHelpers.innerHTML( div.getElementsByTagName( "span" )[ 0 ] ), "Test: works!", "Named partial updates when attr is updated" ); data.get( "greatJoy").set(0, "quite happy" ); - equal( stacheTestHelpers.innerHTML( div.getElementsByTagName( "div" )[ 0 ] ), "quite happy", "Named partial list updates when list item attr is updated" ); + assert.equal( stacheTestHelpers.innerHTML( div.getElementsByTagName( "div" )[ 0 ] ), "quite happy", "Named partial list updates when list item attr is updated" ); data.get( "greatJoy" ).push( "Nintendo Sixty-FOOOOOOOOOOUR" ); - equal( div.getElementsByTagName( "div" ).length, 4, "Named partial list updates with new item" ); + assert.equal( div.getElementsByTagName( "div" ).length, 4, "Named partial list updates with new item" ); }); -test('stache can accept an intermediate with a named partial (canjs/can-stache/issues/3)', function(){ +QUnit.test('stache can accept an intermediate with a named partial (canjs/can-stache/issues/3)', function(assert) { var template = "{{Test:
{{>foo}}
"; var intermediate = parser( template, {}, true ); @@ -213,10 +213,10 @@ test('stache can accept an intermediate with a named partial (canjs/can-stache/i var data = new SimpleMap( {} ); var frag = renderer( data ); - equal( stacheTestHelpers.innerHTML( frag.lastChild ), "bar" ); + assert.equal( stacheTestHelpers.innerHTML( frag.lastChild ), "bar" ); }); -test('named partials can reference each other (canjs/can-stache/issues/3)', function(){ +QUnit.test('named partials can reference each other (canjs/can-stache/issues/3)', function(assert) { var template = "{{bar}}{{/foo}} {{Test:
{{>foo}}
"; var intermediate = parser( template, {}, true ); @@ -224,10 +224,10 @@ test('named partials can reference each other (canjs/can-stache/issues/3)', func var data = new SimpleMap( {} ); var frag = renderer( data ); - equal( stacheTestHelpers.innerHTML( frag.lastChild ), "hello world" ); + assert.equal( stacheTestHelpers.innerHTML( frag.lastChild ), "hello world" ); }); -test( "recursive named partials work (canjs/can-stache/issues/3)", function () { +QUnit.test( "recursive named partials work (canjs/can-stache/issues/3)", function(assert) { var renderer = stache( "{{{{name}}
    {{#each descendants}}{{>foo}}{{/each}}
{{/foo}}
    {{#with ychromosome}}{{>foo}}{{/with}}
" ); var data = new SimpleMap({ ychromosome: { @@ -265,11 +265,11 @@ test( "recursive named partials work (canjs/can-stache/issues/3)", function () { var frag = renderer( data ); var fraghtml = stacheTestHelpers.innerHTML( frag.lastChild ); - equal( (fraghtml.match(/
  • /g) || []).length, 7 ); - ok( fraghtml.indexOf( "
  • goku
    • gohan
        <\/ul><\/li><\/ul><\/li>" ) !== -1 ); + assert.equal( (fraghtml.match(/
      • /g) || []).length, 7 ); + assert.ok( fraghtml.indexOf( "
      • goku
        • gohan
            <\/ul><\/li><\/ul><\/li>" ) !== -1 ); }); -test("Templates can refer to themselves with {{>scope.view .}} (#159)", function() { +QUnit.test("Templates can refer to themselves with {{>scope.view .}} (#159)", function(assert) { var thing = new DefineMap({ child: { hasThing: true, @@ -294,11 +294,11 @@ test("Templates can refer to themselves with {{>scope.view .}} (#159)", function var view = renderer(thing); - equal(view.firstChild.firstChild.innerHTML, "", "Got the second span"); - equal(view.firstChild.firstChild.firstChild.firstChild, undefined, "It stopped there"); + assert.equal(view.firstChild.firstChild.innerHTML, "", "Got the second span"); + assert.equal(view.firstChild.firstChild.firstChild.firstChild, undefined, "It stopped there"); }); -test("Self-referential templates assume 'this'", function() { +QUnit.test("Self-referential templates assume 'this'", function(assert) { var thing = new DefineMap({ child: { hasThing: true, @@ -323,11 +323,11 @@ test("Self-referential templates assume 'this'", function() { var view = renderer(thing); - equal(view.firstChild.firstChild.innerHTML, "", "Got the second span"); - equal(view.firstChild.firstChild.firstChild.firstChild, undefined, "It stopped there"); + assert.equal(view.firstChild.firstChild.innerHTML, "", "Got the second span"); + assert.equal(view.firstChild.firstChild.firstChild.firstChild, undefined, "It stopped there"); }); -test("Self-referential templates work with partial templates", function() { +QUnit.test("Self-referential templates work with partial templates", function(assert) { var thing = new DefineMap({ child: { hasThing: true, @@ -356,10 +356,10 @@ test("Self-referential templates work with partial templates", function() { var view = renderer(thing); - equal(view.firstChild.firstChild.nodeValue, "foo", "Got the second span"); + assert.equal(view.firstChild.firstChild.nodeValue, "foo", "Got the second span"); }); -test("Self-referential templates can be given scope", function() { +QUnit.test("Self-referential templates can be given scope", function(assert) { var thing = new DefineMap({ child: { someProp: 1, @@ -386,10 +386,10 @@ test("Self-referential templates can be given scope", function() { var view = renderer(thing); - equal(view.firstChild.firstChild.nodeValue, "1", "It got the passed scope"); + assert.equal(view.firstChild.firstChild.nodeValue, "1", "It got the passed scope"); }); -test("Partials with custom context", function () { +QUnit.test("Partials with custom context", function(assert) { var template; var div = document.createElement('div'); @@ -409,12 +409,12 @@ test("Partials with custom context", function () { div.appendChild(dom); var spans = div.getElementsByTagName('span'); - equal(spans.length, 2, 'Got two dudes'); - equal(stacheTestHelpers.innerHTML(spans[0]), 'austin', 'custom context inside'); - equal(stacheTestHelpers.innerHTML(spans[1]), 'justin', 'custom context inside'); + assert.equal(spans.length, 2, 'Got two dudes'); + assert.equal(stacheTestHelpers.innerHTML(spans[0]), 'austin', 'custom context inside'); + assert.equal(stacheTestHelpers.innerHTML(spans[1]), 'justin', 'custom context inside'); }); -test("Partials with nested custom context and parent lookup", function () { +QUnit.test("Partials with nested custom context and parent lookup", function(assert) { var template; var div = document.createElement('div'); @@ -441,12 +441,12 @@ test("Partials with nested custom context and parent lookup", function () { div.appendChild(dom); var spans = div.getElementsByTagName('span'); - equal(spans.length, 2, 'Got two dudes'); - equal(stacheTestHelpers.innerHTML(spans[0]), 'Hello austin', 'correct context'); - equal(stacheTestHelpers.innerHTML(spans[1]), 'Hello justin', 'and parent lookup worked also'); + assert.equal(spans.length, 2, 'Got two dudes'); + assert.equal(stacheTestHelpers.innerHTML(spans[0]), 'Hello austin', 'correct context'); + assert.equal(stacheTestHelpers.innerHTML(spans[1]), 'Hello justin', 'and parent lookup worked also'); }); -test("Partials with custom context and helper", function () { +QUnit.test("Partials with custom context and helper", function(assert) { var template; var div = document.createElement('div'); @@ -471,9 +471,9 @@ test("Partials with custom context and helper", function () { div.appendChild(dom); var spans = div.getElementsByTagName('span'); - equal(spans.length, 2, 'Got two dudes'); - equal(stacheTestHelpers.innerHTML(spans[0]), 'Austin', 'correct context'); - equal(stacheTestHelpers.innerHTML(spans[1]), 'Justin', 'and helpers worked also'); + assert.equal(spans.length, 2, 'Got two dudes'); + assert.equal(stacheTestHelpers.innerHTML(spans[0]), 'Austin', 'correct context'); + assert.equal(stacheTestHelpers.innerHTML(spans[1]), 'Justin', 'and helpers worked also'); }); /* @@ -487,15 +487,15 @@ QUnit.test("can pass values to partials as let scope", function(){ address: address }); - QUnit.equal(frag.firstChild.firstChild.innerHTML, "Stave, Chicago"); + assert.equal(frag.firstChild.firstChild.innerHTML, "Stave, Chicago"); });*/ -QUnit.test("Using call expressions works and passes the nodeList", 2, function(){ +QUnit.test("Using call expressions works and passes the nodeList", 2, function(assert) { var addressView = stache("
            {{this.street}}
            "); var addressPartial = function(data, nodeList){ - QUnit.ok(nodeList, true, "has a nodelist"); + assert.ok(nodeList, true, "has a nodelist"); return addressView.apply(this, arguments); }; addressPartial[canSymbol.for("can.isView")] = true; @@ -508,10 +508,10 @@ QUnit.test("Using call expressions works and passes the nodeList", 2, function() } }); - QUnit.equal(frag.firstChild.firstChild.innerHTML, "Stave"); + assert.equal(frag.firstChild.firstChild.innerHTML, "Stave"); }); -QUnit.test("inline partials are accessible from call expressions", 1, function(){ +QUnit.test("inline partials are accessible from call expressions", 1, function(assert) { var view = stache( "{{{{this.street}}{{/addressPartial}}"+ @@ -524,10 +524,10 @@ QUnit.test("inline partials are accessible from call expressions", 1, function() } }); - QUnit.equal(frag.firstChild.firstChild.innerHTML, "Stave"); + assert.equal(frag.firstChild.firstChild.innerHTML, "Stave"); }); -QUnit.test("recursive inline partials are accessible from call expressions", 1, function(){ +QUnit.test("recursive inline partials are accessible from call expressions", 1, function(assert) { var view = stache( "{{{{ bar() }}

            " ); var frag = renderer(); - equal( stacheTestHelpers.innerHTML( frag.lastChild ), "bar" ); + assert.equal( stacheTestHelpers.innerHTML( frag.lastChild ), "bar" ); }); diff --git a/test/stache-define-test.js b/test/stache-define-test.js index 1dde176e..96dfda49 100644 --- a/test/stache-define-test.js +++ b/test/stache-define-test.js @@ -6,7 +6,7 @@ var define = require("can-define"); QUnit.module("can-stache with can-define"); -test("basic replacement and updating", function(){ +QUnit.test("basic replacement and updating", function(assert) { var map = new DefineMap({ message: "World" @@ -15,11 +15,11 @@ test("basic replacement and updating", function(){ var frag = stashed(map); - equal( frag.firstChild.firstChild.nodeValue, "World","got back the right text"); + assert.equal( frag.firstChild.firstChild.nodeValue, "World","got back the right text"); }); -test('Helper each inside a text section (attribute) (#8)', function(assert){ +QUnit.test('Helper each inside a text section (attribute) (#8)', function(assert){ var template = stache('
            '); var vm = new DefineMap({ @@ -36,7 +36,7 @@ test('Helper each inside a text section (attribute) (#8)', function(assert){ assert.equal( className, 'one two three ' ); }); -test("Using #each on a DefineMap", function(assert){ +QUnit.test("Using #each on a DefineMap", function(assert){ var template = stache("{{#each obj}}{{%key}}{{.}}{{/each}}"); var VM = DefineMap.extend({ @@ -67,19 +67,19 @@ test("Using #each on a DefineMap", function(assert){ assert.equal(third.nextSibling.nodeValue, "qux"); }); -QUnit.test("{{%index}} work with {{#key}} iteration", function () { +QUnit.test("{{%index}} work with {{#key}} iteration", function(assert) { var template = stache('

            {{#iter}}{{%index}}{{/iter}}

            '); var div = document.createElement('div'); var dom = template({iter: new DefineList(['hey', 'there'])}); div.appendChild(dom); var span = div.getElementsByTagName('span'); - equal((span[0].innerHTML), '0', 'iteration for %index'); - equal((span[1].innerHTML), '1', 'iteration for %index'); + assert.equal((span[0].innerHTML), '0', 'iteration for %index'); + assert.equal((span[1].innerHTML), '1', 'iteration for %index'); }); // cf. https://github.com/canjs/can-stache/issues/180 -QUnit.test("Renders live bound `{{defineList[0]}}` and `{{defineList.0}}` data (#180)", function() { +QUnit.test("Renders live bound `{{defineList[0]}}` and `{{defineList.0}}` data (#180)", function(assert) { var list = new DefineList([ 'zero' ]); var renderer = stache('
            {{list[0]}}{{list.0}}'); //var html = renderer({ list: list }); @@ -91,15 +91,15 @@ QUnit.test("Renders live bound `{{defineList[0]}}` and `{{defineList.0}}` data ( // zero // zero //
            - equal(html.querySelector('.brackets').textContent, 'zero', '{{list[0]}}'); - equal(html.querySelector('.dot').textContent, 'zero', '{{list.0}}'); + assert.equal(html.querySelector('.brackets').textContent, 'zero', '{{list[0]}}'); + assert.equal(html.querySelector('.dot').textContent, 'zero', '{{list.0}}'); list.set(0, 'even'); - equal(html.querySelector('.brackets').textContent, 'even', '{{list[0]}} set as list.set(0, even)'); - equal(html.querySelector('.dot').textContent, 'even', '{{list.0}} set as list.set(0, even)'); + assert.equal(html.querySelector('.brackets').textContent, 'even', '{{list[0]}} set as list.set(0, even)'); + assert.equal(html.querySelector('.dot').textContent, 'even', '{{list.0}} set as list.set(0, even)'); }); -QUnit.test("Renders #each live bound `defineList[%index]` data (#180)", function() { +QUnit.test("Renders #each live bound `defineList[%index]` data (#180)", function(assert) { var list = new DefineList([true, false, true]); var renderer = stache('
            {{#each list}}{{/each}}
            '); var html = renderer({ list: list }); @@ -110,29 +110,29 @@ QUnit.test("Renders #each live bound `defineList[%index]` data (#180)", function // // // - equal(html.querySelectorAll('input').length, 3, 'three checkboxes'); - equal(html.querySelector('[value="0"]').className, 'selected', 'first IS selected'); - equal(html.querySelector('[value="1"]').className, '', 'second NOT selected'); - equal(html.querySelector('[value="2"]').className, 'selected', 'third IS selected'); + assert.equal(html.querySelectorAll('input').length, 3, 'three checkboxes'); + assert.equal(html.querySelector('[value="0"]').className, 'selected', 'first IS selected'); + assert.equal(html.querySelector('[value="1"]').className, '', 'second NOT selected'); + assert.equal(html.querySelector('[value="2"]').className, 'selected', 'third IS selected'); list.set(0, false); list[1] = true; list[2] = false; list.push(true); - equal(html.querySelectorAll('input').length, 4, 'AFTER DATA CHANGES: four checkboxes'); - equal(html.querySelector('[value="0"]').className, '', 'first NOT selected'); - equal(html.querySelector('[value="1"]').className, 'selected', 'second IS selected'); - equal(html.querySelector('[value="2"]').className, '', 'third NOT selected'); - equal(html.querySelector('[value="3"]').className, 'selected', 'fourth IS selected'); + assert.equal(html.querySelectorAll('input').length, 4, 'AFTER DATA CHANGES: four checkboxes'); + assert.equal(html.querySelector('[value="0"]').className, '', 'first NOT selected'); + assert.equal(html.querySelector('[value="1"]').className, 'selected', 'second IS selected'); + assert.equal(html.querySelector('[value="2"]').className, '', 'third NOT selected'); + assert.equal(html.querySelector('[value="3"]').className, 'selected', 'fourth IS selected'); list.shift(); list.pop(); - equal(html.querySelectorAll('input').length, 2, 'AFTER DATA CHANGES: two checkboxes'); - equal(html.querySelector('[value="0"]').className, 'selected', 'first IS selected'); - equal(html.querySelector('[value="1"]').className, '', 'second NOT selected'); + assert.equal(html.querySelectorAll('input').length, 2, 'AFTER DATA CHANGES: two checkboxes'); + assert.equal(html.querySelector('[value="0"]').className, 'selected', 'first IS selected'); + assert.equal(html.querySelector('[value="1"]').className, '', 'second NOT selected'); }); -QUnit.test("iterate a DefineMap with {{#each}} (#can-define/125)", function(){ +QUnit.test("iterate a DefineMap with {{#each}} (#can-define/125)", function(assert) { var template = stache('

            {{#each iter}}{{%key}} {{.}}{{/each}}

            '); var div = document.createElement('div'); @@ -140,11 +140,11 @@ QUnit.test("iterate a DefineMap with {{#each}} (#can-define/125)", function(){ div.appendChild(dom); var span = div.getElementsByTagName('span'); - equal((span[0].innerHTML), 'first justin', 'first'); - equal((span[1].innerHTML), 'last meyer', 'last'); + assert.equal((span[0].innerHTML), 'first justin', 'first'); + assert.equal((span[1].innerHTML), 'last meyer', 'last'); }); -QUnit.test("Stache with single property", function() { +QUnit.test("Stache with single property", function(assert) { var Typer = define.Constructor({ foo: { type: 'string' @@ -156,12 +156,12 @@ QUnit.test("Stache with single property", function() { foo: 'bar' }); var frag = template(t); - equal(frag.firstChild.nodeValue, 'bar'); + assert.equal(frag.firstChild.nodeValue, 'bar'); t.foo = "baz"; - equal(frag.firstChild.nodeValue, 'baz'); + assert.equal(frag.firstChild.nodeValue, 'baz'); }); -QUnit.test("stache with double property", function() { +QUnit.test("stache with double property", function(assert) { var nailedIt = 'Nailed it'; var Example = define.Constructor({ name: { @@ -197,10 +197,10 @@ QUnit.test("stache with double property", function() { var nested = new NestedMap(); var template = stache('{{test.name}}'); var frag = template(nested); - equal(frag.firstChild.nodeValue, nailedIt); + assert.equal(frag.firstChild.nodeValue, nailedIt); }); -QUnit.test("Stache with one nested property", function() { +QUnit.test("Stache with one nested property", function(assert) { var nailedIt = 'Nailed it'; var Example = define.Constructor({ name: { @@ -236,10 +236,10 @@ QUnit.test("Stache with one nested property", function() { var nested = new NestedMap(); var template = stache('{{examples.one.name}}'); var frag = template(nested); - equal(frag.firstChild.nodeValue, nailedIt); + assert.equal(frag.firstChild.nodeValue, nailedIt); }); -QUnit.test("Stache with two nested property", function() { +QUnit.test("Stache with two nested property", function(assert) { var nailedIt = 'Nailed it'; var Example = define.Constructor({ name: { @@ -275,10 +275,10 @@ QUnit.test("Stache with two nested property", function() { var nested = new NestedMap(); var template = stache('{{examples.two.deep.name}}'); var frag = template(nested); - equal(frag.firstChild.nodeValue, nailedIt); + assert.equal(frag.firstChild.nodeValue, nailedIt); }); -test('list.sort a list of DefineMaps', function(){ +QUnit.test('list.sort a list of DefineMaps', function(assert) { var Account = DefineMap.extend({ name: "string", @@ -314,7 +314,7 @@ test('list.sort a list of DefineMaps', function(){ accounts.limit = 3; var template = stache('{{#each accounts}}{{name}},{{/each}}')({accounts: accounts}); - equal(template.textContent, "Savings,Checking,Kids Savings,", "template rendered properly."); + assert.equal(template.textContent, "Savings,Checking,Kids Savings,", "template rendered properly."); accounts.sort(function(a, b){ if (a.name < b.name) { @@ -325,8 +325,8 @@ test('list.sort a list of DefineMaps', function(){ return 0; } }); - equal(accounts.length, 3); - equal(template.textContent, "Checking,Kids Savings,Savings,", "template updated properly."); + assert.equal(accounts.length, 3); + assert.equal(template.textContent, "Checking,Kids Savings,Savings,", "template updated properly."); // Try sorting in reverse on the dynamic `slug` property accounts.sort(function(a, b){ @@ -339,7 +339,7 @@ test('list.sort a list of DefineMaps', function(){ } }); - equal(accounts.length, 3); - equal(accounts.limit, 3, "expandos still present after sorting/replacing."); - equal(template.textContent, "Savings,Kids Savings,Checking,", "template updated properly."); + assert.equal(accounts.length, 3); + assert.equal(accounts.limit, 3, "expandos still present after sorting/replacing."); + assert.equal(template.textContent, "Savings,Kids Savings,Checking,", "template updated properly."); }); diff --git a/test/stache-test.js b/test/stache-test.js index f08d368a..fee44179 100644 --- a/test/stache-test.js +++ b/test/stache-test.js @@ -127,7 +127,7 @@ function makeTest(name, doc, mutation) { var oldDoc; QUnit.module(name, { - setup: function(){ + beforeEach: function(assert) { if(doc === window.document) { DOCUMENT(null); globals.deleteKeyValue('MutationObserver'); @@ -148,29 +148,29 @@ function makeTest(name, doc, mutation) { // the previous test do not conflict with scope properties helpersCore.__resetHelpers(); }, - teardown: function(){ + afterEach: function(assert) { doc.body.removeChild(this.fixture); - stop(); + var done = assert.async(); setTimeout(function(){ DOCUMENT(window.document); globals.deleteKeyValue('MutationObserver'); - start(); + done(); },1) } }); - test("html to html", function(){ + QUnit.test("html to html", function(assert) { var stashed = stache("

            Hello World!

            "); var frag = stashed(); - equal( innerHTML(frag.childNodes.item(0)).toLowerCase(), "hello world!","got back the right text"); + assert.equal( innerHTML(frag.childNodes.item(0)).toLowerCase(), "hello world!","got back the right text"); }); - test("basic replacement", function(){ + QUnit.test("basic replacement", function(assert) { var stashed = stache("

            Hello {{message}}!

            "); @@ -178,10 +178,10 @@ function makeTest(name, doc, mutation) { var frag = stashed({ message: "World" }); - equal( innerHTML(frag.firstChild).toLowerCase(), "hello world!","got back the right text"); + assert.equal( innerHTML(frag.firstChild).toLowerCase(), "hello world!","got back the right text"); }); - QUnit.test("a section helper", function(){ + QUnit.test("a section helper", function(assert) { stache.registerHelper("helper", function(options){ @@ -194,9 +194,9 @@ function makeTest(name, doc, mutation) { var frag = stashed({}); - equal(frag.firstChild.firstChild.nodeName.toLowerCase(), "span", "got a span"); + assert.equal(frag.firstChild.firstChild.nodeName.toLowerCase(), "span", "got a span"); - equal(innerHTML(frag.firstChild.firstChild), "Hello World!","got back the right text"); + assert.equal(innerHTML(frag.firstChild.firstChild), "Hello World!","got back the right text"); }); @@ -228,30 +228,30 @@ function makeTest(name, doc, mutation) { stache(template)(viewModel); }); - testHelpers.dev.devOnlyTest("helpers warn on overwrite (canjs/can-stache-converters#24)", function () { + testHelpers.dev.devOnlyTest("helpers warn on overwrite (canjs/can-stache-converters#24)", function (assert) { stache.registerHelper('foobar', function() {}); // have to do this after the first registration b/c if the dom and vdom tests run, "foobar" // will already have been registered. var teardown = testHelpers.dev.willWarn(/already been registered/, function(message, matched) { if(matched) { - ok(true, "received warning"); + assert.ok(true, "received warning"); } }); stache.registerHelper('foobar', function() {}); - QUnit.equal(teardown(), 1, "Exactly one warning called"); + assert.equal(teardown(), 1, "Exactly one warning called"); }); - test("attributes sections", function(){ + QUnit.test("attributes sections", function(assert) { var template = stache("
            "); var frag = template({ attributes: "foo='bar'" }); - equal(frag.firstChild.getAttribute('foo'), "bar", "{{attributes}} set"); + assert.equal(frag.firstChild.getAttribute('foo'), "bar", "{{attributes}} set"); template = stache("
            "); @@ -260,19 +260,19 @@ function makeTest(name, doc, mutation) { baz: "bar" }); - equal(frag.firstChild.getAttribute('foo'), "bar", "foo='{{baz}}' set"); + assert.equal(frag.firstChild.getAttribute('foo'), "bar", "foo='{{baz}}' set"); frag = template({ truthy: false, baz: "bar" }); - equal(frag.firstChild.getAttribute('foo'), null, "attribute not set if not truthy"); + assert.equal(frag.firstChild.getAttribute('foo'), null, "attribute not set if not truthy"); }); - test("boxes example", function(){ + QUnit.test("boxes example", function(assert) { var boxes = [], Box = DefineMap.extend({ count: {value: 0}, @@ -307,24 +307,24 @@ function makeTest(name, doc, mutation) { //equal(frag.children.length, 2, "there are 2 childNodes"); - ok(/top: 0px/.test( frag.firstChild.firstChild.getAttribute("style") ), "0px"); + assert.ok(/top: 0px/.test( frag.firstChild.firstChild.getAttribute("style") ), "0px"); boxes[0].tick(); - ok(! /top: 0px/.test( frag.firstChild.firstChild.getAttribute("style")) , "!0px"); + assert.ok(! /top: 0px/.test( frag.firstChild.firstChild.getAttribute("style")) , "!0px"); }); - test('Tokens returning 0 where they should display the number', function () { + QUnit.test('Tokens returning 0 where they should display the number', function(assert) { var template = "
            {{completed}}
            "; var frag = stache( template )({ completed: 0 }); - equal( frag.firstChild.firstChild.nodeValue, "0", 'zero shown' ); + assert.equal( frag.firstChild.firstChild.nodeValue, "0", 'zero shown' ); }); - test('Inverted section function returning numbers', function () { + QUnit.test('Inverted section function returning numbers', function(assert) { var template = "
            {{^todos.completed()}}hidden{{/todos.completed}}
            "; var obsvr = new SimpleMap({ named: false @@ -341,16 +341,16 @@ function makeTest(name, doc, mutation) { todos: todos }); - deepEqual(frag.firstChild.firstChild.nodeValue, "hidden", 'hidden shown'); + assert.deepEqual(frag.firstChild.firstChild.nodeValue, "hidden", 'hidden shown'); // now update the named attribute obsvr.set('named', true); - deepEqual(frag.firstChild.firstChild.nodeValue, "", 'hidden gone'); + assert.deepEqual(frag.firstChild.firstChild.nodeValue, "", 'hidden gone'); }); - test("live-binding with escaping", function () { + QUnit.test("live-binding with escaping", function(assert) { var template = "{{ name }}{{{name}}}"; var teacher = new SimpleMap({ @@ -361,18 +361,18 @@ function makeTest(name, doc, mutation) { var frag = tpl(teacher); - deepEqual(innerHTML(frag.firstChild), "<strong>Mrs Peters</strong>"); - deepEqual(innerHTML(frag.lastChild.firstChild), "Mrs Peters"); + assert.deepEqual(innerHTML(frag.firstChild), "<strong>Mrs Peters</strong>"); + assert.deepEqual(innerHTML(frag.lastChild.firstChild), "Mrs Peters"); teacher.set('name', 'Mr Scott'); - deepEqual(innerHTML(frag.firstChild), "<i>Mr Scott</i>"); + assert.deepEqual(innerHTML(frag.firstChild), "<i>Mr Scott</i>"); - deepEqual(innerHTML(frag.lastChild.firstChild), "Mr Scott"); + assert.deepEqual(innerHTML(frag.lastChild.firstChild), "Mr Scott"); }); - test("truthy", function () { + QUnit.test("truthy", function(assert) { var t = { template: "{{#name}}Do something, {{this}}!{{/name}}", expected: "Do something, Andy!", @@ -384,10 +384,10 @@ function makeTest(name, doc, mutation) { var expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual( getText( t.template , t.data), expected); + assert.deepEqual( getText( t.template , t.data), expected); }); - test("falsey", function () { + QUnit.test("falsey", function(assert) { var t = { template: "{{^cannot}}Don't do it, {{name}}!{{/cannot}}", expected: "Don't do it, Andy!", @@ -398,10 +398,10 @@ function makeTest(name, doc, mutation) { var expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual(getText( t.template, t.data), expected); + assert.deepEqual(getText( t.template, t.data), expected); }); - QUnit.test("Handlebars helpers", function () { + QUnit.test("Handlebars helpers", function(assert) { stache.registerHelper('hello', function (options) { return 'Should not hit this'; }); @@ -430,10 +430,10 @@ function makeTest(name, doc, mutation) { var expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual( getText(t.template, t.data) , expected); + assert.deepEqual( getText(t.template, t.data) , expected); }); - QUnit.test("Handlebars advanced helpers (from docs)", function () { + QUnit.test("Handlebars advanced helpers (from docs)", function(assert) { stache.addHelper('exercise', function (group, action, num, options) { if (group && group.length > 0 && action && num > 0) { @@ -470,12 +470,12 @@ function makeTest(name, doc, mutation) { var div = doc.createElement("div"); div.appendChild(frag); - equal(innerHTML( div ), t.expected); + assert.equal(innerHTML( div ), t.expected); - equal(getText(t.template, {}), t.expected2); + assert.equal(getText(t.template, {}), t.expected2); }); - test("Passing functions as data, then executing them", function () { + QUnit.test("Passing functions as data, then executing them", function(assert) { var t = { template: "{{#nested}}{{welcome ../name}}{{/nested}}", expected: "Welcome Andy!", @@ -491,10 +491,10 @@ function makeTest(name, doc, mutation) { var expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual( getText(t.template, t.data), expected); + assert.deepEqual( getText(t.template, t.data), expected); }); - test("No arguments passed to helper", function () { + QUnit.test("No arguments passed to helper", function(assert) { var template = stache("{{noargHelper()}}"); stache.registerHelper("noargHelper", function () { @@ -506,11 +506,11 @@ function makeTest(name, doc, mutation) { div1.appendChild(template({})); div2.appendChild(template(new SimpleMap())); - deepEqual(innerHTML(div1), "foo"); - deepEqual(innerHTML(div2), "foo"); + assert.deepEqual(innerHTML(div1), "foo"); + assert.deepEqual(innerHTML(div2), "foo"); }); - QUnit.test("String literals passed to helper should work (#1143)", 1, function() { + QUnit.test("String literals passed to helper should work (#1143)", 1, function(assert) { stache.registerHelper("concatStrings", function(arg1, arg2) { return arg1 + arg2; }); @@ -521,10 +521,10 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(template({})); - equal(innerHTML(div), '==word'); + assert.equal(innerHTML(div), '==word'); }); - test("No arguments passed to helper with list", function () { + QUnit.test("No arguments passed to helper with list", function(assert) { var template = stache("{{#items}}{{noargHelper()}}{{/items}}"); var div = doc.createElement('div'); @@ -538,11 +538,11 @@ function makeTest(name, doc, mutation) { } })); - deepEqual(innerHTML(div), "foo"); + assert.deepEqual(innerHTML(div), "foo"); }); if(isNormalDOM) { - test("Partials and observes", function () { + QUnit.test("Partials and observes", function(assert) { var template; var div = doc.createElement('div'); @@ -560,13 +560,13 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var ths = div.getElementsByTagName('th'); - equal(ths.length, 2, 'Got two table headings'); - equal(innerHTML(ths[0]), 'hi', 'First column heading correct'); - equal(innerHTML(ths[1]), 'there', 'Second column heading correct'); + assert.equal(ths.length, 2, 'Got two table headings'); + assert.equal(innerHTML(ths[0]), 'hi', 'First column heading correct'); + assert.equal(innerHTML(ths[1]), 'there', 'Second column heading correct'); }); } - test("Handlebars helper: if/else", function () { + QUnit.test("Handlebars helper: if/else", function(assert) { var expected; var t = { template: "{{#if name}}{{name}}{{/if}}{{#if missing}} is missing!{{/if}}", @@ -579,15 +579,15 @@ function makeTest(name, doc, mutation) { expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual(getText(t.template,t.data), expected); + assert.deepEqual(getText(t.template,t.data), expected); t.data.missing = null; expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual(getText(t.template,t.data), expected); + assert.deepEqual(getText(t.template,t.data), expected); }); - test("Handlebars helper: unless", function () { + QUnit.test("Handlebars helper: unless", function(assert) { var t = { template: "{{#unless missing}}Andy is missing!{{/unless}}" + "{{#unless isCool}} But he wasn't cool anyways.{{/unless}}", @@ -613,14 +613,14 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(stache(t.template)(t.liveData)); - deepEqual( innerHTML(div), expected, '#unless condition false = '+expected); + assert.deepEqual( innerHTML(div), expected, '#unless condition false = '+expected); t.liveData.set('missing', true); - deepEqual( innerHTML(div), '', '#unless condition true'); + assert.deepEqual( innerHTML(div), '', '#unless condition true'); }); - test("Handlebars helper: each", function () { + QUnit.test("Handlebars helper: each", function(assert) { var t = { template: "{{#each names}}{{this}} {{/each}}", expected: "Andy Austin Justin ", @@ -635,17 +635,17 @@ function makeTest(name, doc, mutation) { var expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual( getText(t.template,t.data) , expected); + assert.deepEqual( getText(t.template,t.data) , expected); var div = doc.createElement('div'); div.appendChild(stache(t.template)(t.data2)); - deepEqual( innerHTML(div), expected, 'Using Observe.List'); + assert.deepEqual( innerHTML(div), expected, 'Using Observe.List'); t.data2.names.push('What'); }); - test("Handlebars helper: with", function () { + QUnit.test("Handlebars helper: with", function(assert) { var t = { template: "{{#with person}}{{name}}{{/with}}", expected: "Andy", @@ -658,7 +658,7 @@ function makeTest(name, doc, mutation) { var expected = t.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual(getText(t.template,t.data), expected, '#with person'); + assert.deepEqual(getText(t.template,t.data), expected, '#with person'); var v = { template: "{{#with person}}{{name}}{{/with}}", @@ -671,10 +671,10 @@ function makeTest(name, doc, mutation) { expected = v.expected.replace(/"/g, '"') .replace(/\r\n/g, '\n'); - deepEqual(getText(v.template,v.data), expected, '#with person - person === null'); + assert.deepEqual(getText(v.template,v.data), expected, '#with person - person === null'); }); - test("render with double angle", function () { + QUnit.test("render with double angle", function(assert) { var text = "{{& replace_me }}{{{ replace_me_too }}}" + "
              {{#animals}}" + "
            • {{.}}
            • " + @@ -682,10 +682,10 @@ function makeTest(name, doc, mutation) { var compiled = getText(text,{ animals: this.animals }); - equal(compiled, "
              • sloth
              • bear
              • monkey
              ", "works") + assert.equal(compiled, "
              • sloth
              • bear
              • monkey
              ", "works") }); - test("comments", function () { + QUnit.test("comments", function(assert) { var text = "{{! replace_me }}" + "
                {{#animals}}" + "
              • {{.}}
              • " + @@ -694,23 +694,23 @@ function makeTest(name, doc, mutation) { var compiled = getText(text,{ animals: this.animals }); - equal(compiled, "
                • sloth
                • bear
                • monkey
                ") + assert.equal(compiled, "
                • sloth
                • bear
                • monkey
                ") }); - test("multi line", function () { + QUnit.test("multi line", function(assert) { var text = "a \n b \n c"; - equal(getTextFromFrag( stache(text)({}) ), text) + assert.equal(getTextFromFrag( stache(text)({}) ), text) }); - test("multi line elements", function () { + QUnit.test("multi line elements", function(assert) { var text = "", result = stache(text)({myClass: 'a'}); - equal(result.firstChild.className, "a", "class name is right"); + assert.equal(result.firstChild.className, "a", "class name is right"); }); - test("escapedContent", function () { + QUnit.test("escapedContent", function(assert) { var text = "{{ tags }}{{ number }}"; var div = doc.createElement('div'); @@ -721,13 +721,13 @@ function makeTest(name, doc, mutation) { number: 123 }) ); - equal(div.getElementsByTagName('span')[0].firstChild.nodeValue, "foo < bar < car > zar > poo"); - equal(div.getElementsByTagName('strong')[0].firstChild.nodeValue, 123); - equal(div.getElementsByTagName('input')[0].value, "I use 'quote' fingers & &ersands \"a lot\"", "attributes are always safe, and strings are kept as-is without additional escaping"); - equal( innerHTML(div.getElementsByTagName('label')[0]), "&", "text-based html entities work fine"); + assert.equal(div.getElementsByTagName('span')[0].firstChild.nodeValue, "foo < bar < car > zar > poo"); + assert.equal(div.getElementsByTagName('strong')[0].firstChild.nodeValue, 123); + assert.equal(div.getElementsByTagName('input')[0].value, "I use 'quote' fingers & &ersands \"a lot\"", "attributes are always safe, and strings are kept as-is without additional escaping"); + assert.equal( innerHTML(div.getElementsByTagName('label')[0]), "&", "text-based html entities work fine"); }); - test("unescapedContent", function () { + QUnit.test("unescapedContent", function(assert) { var text = "{{{ tags }}}
                {{{ tags }}}
                "; var div = doc.createElement('div'); @@ -736,13 +736,13 @@ function makeTest(name, doc, mutation) { quotes: 'I use \'quote\' fingers "a lot"' }) ); - equal(div.getElementsByTagName('span')[0].firstChild.nodeType, 1,""); - equal( innerHTML(div.getElementsByTagName('div')[0]).toLowerCase(), "foobar"); - equal( innerHTML(div.getElementsByTagName('span')[0]).toLowerCase(), "foobar"); - equal(div.getElementsByTagName('input')[0].value, "I use 'quote' fingers \"a lot\"", "escaped no matter what"); + assert.equal(div.getElementsByTagName('span')[0].firstChild.nodeType, 1,""); + assert.equal( innerHTML(div.getElementsByTagName('div')[0]).toLowerCase(), "foobar"); + assert.equal( innerHTML(div.getElementsByTagName('span')[0]).toLowerCase(), "foobar"); + assert.equal(div.getElementsByTagName('input')[0].value, "I use 'quote' fingers \"a lot\"", "escaped no matter what"); }); - test("attribute single unescaped, html single unescaped", function () { + QUnit.test("attribute single unescaped, html single unescaped", function(assert) { var text = "
                {{ task.name }}
                "; var task = new SimpleMap({ @@ -755,20 +755,20 @@ function makeTest(name, doc, mutation) { task: task })); - equal( innerHTML(div.getElementsByTagName('div')[0]), "dishes", "html correctly dishes") - equal(div.getElementsByTagName('div')[0].className, "", "class empty") + assert.equal( innerHTML(div.getElementsByTagName('div')[0]), "dishes", "html correctly dishes") + assert.equal(div.getElementsByTagName('div')[0].className, "", "class empty") task.set('name', 'lawn') - equal( innerHTML(div.getElementsByTagName('div')[0]), "lawn", "html correctly lawn") - equal(div.getElementsByTagName('div')[0].className, "", "class empty") + assert.equal( innerHTML(div.getElementsByTagName('div')[0]), "lawn", "html correctly lawn") + assert.equal(div.getElementsByTagName('div')[0].className, "", "class empty") task.set('completed', true); - equal(div.getElementsByTagName('div')[0].className, "complete", "class changed to complete") + assert.equal(div.getElementsByTagName('div')[0].className, "complete", "class changed to complete") }); - test("select live binding", function () { + QUnit.test("select live binding", function(assert) { var text = ""; var todos, div; todos = new DefineList([{ @@ -780,22 +780,22 @@ function makeTest(name, doc, mutation) { div.appendChild( stache(text)({todos: todos}) ); - equal(div.getElementsByTagName('option') + assert.equal(div.getElementsByTagName('option') .length, 1, '1 item in list') todos.push({ id: 2, name: 'Laundry' }); - equal(div.getElementsByTagName('option') + assert.equal(div.getElementsByTagName('option') .length, 2, '2 items in list') todos.splice(0, 2); - equal(div.getElementsByTagName('option') + assert.equal(div.getElementsByTagName('option') .length, 0, '0 items in list') }); - test('multiple hookups in a single attribute', function () { + QUnit.test('multiple hookups in a single attribute', function(assert) { var text = '
                '; @@ -817,22 +817,22 @@ function makeTest(name, doc, mutation) { var innerDiv = div.firstChild; - equal(getAttr(innerDiv, 'class'), "abcd", 'initial render'); + assert.equal(getAttr(innerDiv, 'class'), "abcd", 'initial render'); obs.set('bar', 'e'); - equal(getAttr(innerDiv, 'class'), "aecd", 'initial render'); + assert.equal(getAttr(innerDiv, 'class'), "aecd", 'initial render'); obs.set('bar', 'f'); - equal(getAttr(innerDiv, 'class'), "afcd", 'initial render'); + assert.equal(getAttr(innerDiv, 'class'), "afcd", 'initial render'); obs.get('nest').set('what', 'g'); - equal(getAttr(innerDiv, 'class'), "afcg", 'nested observe'); + assert.equal(getAttr(innerDiv, 'class'), "afcg", 'nested observe'); }); - test('adding and removing multiple html content within a single element', function () { + QUnit.test('adding and removing multiple html content within a single element', function(assert) { var text, obs; @@ -851,7 +851,7 @@ function makeTest(name, doc, mutation) { obs: obs })); - equal( innerHTML(div.firstChild), 'abc', 'initial render'); + assert.equal( innerHTML(div.firstChild), 'abc', 'initial render'); obs.set({ a: '', @@ -859,16 +859,16 @@ function makeTest(name, doc, mutation) { c: '' }); - equal(innerHTML(div.firstChild), '', 'updated values'); + assert.equal(innerHTML(div.firstChild), '', 'updated values'); obs.set({ c: 'c' }); - equal( innerHTML(div.firstChild), 'c', 'updated values'); + assert.equal( innerHTML(div.firstChild), 'c', 'updated values'); }); - test('live binding and removeAttr', function () { + QUnit.test('live binding and removeAttr', function(assert) { var text = '{{ #obs.show }}' + '

                {{ ../obs.message }}

                ' + '{{ /obs.show }}', @@ -889,51 +889,51 @@ function makeTest(name, doc, mutation) { var p = div.getElementsByTagName('p')[0], span = p.getElementsByTagName('span')[0]; - equal(p.getAttribute("some"), "myText", 'initial render attr'); - equal(getAttr(p, "class"), "myMessage", 'initial render class'); - equal( innerHTML(span), 'Live long and prosper', 'initial render innerHTML'); + assert.equal(p.getAttribute("some"), "myText", 'initial render attr'); + assert.equal(getAttr(p, "class"), "myMessage", 'initial render class'); + assert.equal( innerHTML(span), 'Live long and prosper', 'initial render innerHTML'); obs.set('className', undefined); - equal(getAttr(p, "class"), '', 'class is undefined'); + assert.equal(getAttr(p, "class"), '', 'class is undefined'); obs.set('className', 'newClass'); - equal(getAttr(p, "class"), 'newClass', 'class updated'); + assert.equal(getAttr(p, "class"), 'newClass', 'class updated'); obs.set('attributes',undefined); - equal(p.getAttribute('some'), null, 'attribute is undefined'); + assert.equal(p.getAttribute('some'), null, 'attribute is undefined'); obs.set('attributes', 'some="newText"'); // - equal(p.getAttribute('some'), 'newText', 'attribute updated'); + assert.equal(p.getAttribute('some'), 'newText', 'attribute updated'); obs.set('message',undefined); - equal(innerHTML(span), '', 'text node value is empty'); + assert.equal(innerHTML(span), '', 'text node value is empty'); obs.set('message', 'Warp drive, Mr. Sulu'); - equal(innerHTML(span), 'Warp drive, Mr. Sulu', 'text node updated'); + assert.equal(innerHTML(span), 'Warp drive, Mr. Sulu', 'text node updated'); obs.set('show',undefined); - equal( innerHTML(div), '', 'value in block statement is undefined'); + assert.equal( innerHTML(div), '', 'value in block statement is undefined'); obs.set('show', true); p = div.getElementsByTagName('p')[0]; span = p.getElementsByTagName('span')[0]; - equal(p.getAttribute("some"), "newText", 'value in block statement updated attr'); - equal(getAttr(p, "class"), "newClass", 'value in block statement updated class'); - equal( innerHTML(span), 'Warp drive, Mr. Sulu', 'value in block statement updated innerHTML'); + assert.equal(p.getAttribute("some"), "newText", 'value in block statement updated attr'); + assert.equal(getAttr(p, "class"), "newClass", 'value in block statement updated class'); + assert.equal( innerHTML(span), 'Warp drive, Mr. Sulu', 'value in block statement updated innerHTML'); }); - test('hookup within a tag', function () { + QUnit.test('hookup within a tag', function(assert) { var text = '
                lorem ipsum
                ', obs = new SimpleMap({ @@ -947,24 +947,24 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled); var anchor = div.getElementsByTagName('div')[0]; - equal(getAttr(anchor, 'class'), 'a'); - equal(anchor.getAttribute('some'), 'property'); + assert.equal(getAttr(anchor, 'class'), 'a'); + assert.equal(anchor.getAttribute('some'), 'property'); obs.set('foo', 'class="b"'); - equal(getAttr(anchor, 'class'), 'b'); - equal(anchor.getAttribute('some'), 'property'); + assert.equal(getAttr(anchor, 'class'), 'b'); + assert.equal(anchor.getAttribute('some'), 'property'); obs.set('baz', 'some=\'new property\''); - equal(getAttr(anchor, 'class'), 'b'); - equal(anchor.getAttribute('some'), 'new property'); + assert.equal(getAttr(anchor, 'class'), 'b'); + assert.equal(anchor.getAttribute('some'), 'new property'); obs.set('foo', 'class=""'); obs.set('baz', ''); - equal(getAttr(anchor, 'class'), "", 'anchor class blank'); - equal(anchor.getAttribute('some'), undefined, 'attribute "some" is undefined'); + assert.equal(getAttr(anchor, 'class'), "", 'anchor class blank'); + assert.equal(anchor.getAttribute('some'), undefined, 'attribute "some" is undefined'); }); - test('single escaped tag, removeAttr', function () { + QUnit.test('single escaped tag, removeAttr', function(assert) { var text = '
                lorem ipsum
                ', obs = new SimpleMap({ @@ -977,16 +977,16 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled); var anchor = div.getElementsByTagName('div')[0]; - equal(anchor.getAttribute('data-bar'), "john doe's bar"); + assert.equal(anchor.getAttribute('data-bar'), "john doe's bar"); obs.set('foo',undefined); - equal(anchor.getAttribute('data-bar'), null); + assert.equal(anchor.getAttribute('data-bar'), null); obs.set('foo', 'data-bar="baz"'); - equal(anchor.getAttribute('data-bar'), 'baz'); + assert.equal(anchor.getAttribute('data-bar'), 'baz'); }); - test('html comments', function () { + QUnit.test('html comments', function(assert) { var text = '
                {{obs.foo}}
                '; var obs = new SimpleMap({ @@ -999,10 +999,10 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(compiled); - equal( innerHTML(div.getElementsByTagName('div')[0]), 'foo', 'Element as expected'); + assert.equal( innerHTML(div.getElementsByTagName('div')[0]), 'foo', 'Element as expected'); }); - test("hookup and live binding", function () { + QUnit.test("hookup and live binding", function(assert) { var text = "
                " + "{{ task.name }}" + @@ -1019,21 +1019,21 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled) var child = div.getElementsByTagName('div')[0]; - ok(child.className.indexOf("false") > -1, "is incomplete") - ok( !! domData.get(child, 'task'), "has data") - equal(innerHTML(child), "My Name", "has name") + assert.ok(child.className.indexOf("false") > -1, "is incomplete") + assert.ok( !! domData.get(child, 'task'), "has data") + assert.equal(innerHTML(child), "My Name", "has name") task.set({ completed: true, name: 'New Name' }); - ok(child.className.indexOf("true") !== -1, "is complete") - equal(innerHTML(child), "New Name", "has new name") + assert.ok(child.className.indexOf("true") !== -1, "is complete") + assert.equal(innerHTML(child), "New Name", "has new name") }); - test('multiple curly braces in a block', function () { + QUnit.test('multiple curly braces in a block', function(assert) { var text = '{{^obs.items}}' + '
              • No items
              • ' + '{{/obs.items}}' + @@ -1050,15 +1050,15 @@ function makeTest(name, doc, mutation) { var ul = doc.createElement('ul'); ul.appendChild(compiled); - equal( innerHTML(ul.getElementsByTagName('li')[0]), 'No items', 'initial observable state'); + assert.equal( innerHTML(ul.getElementsByTagName('li')[0]), 'No items', 'initial observable state'); obs.set('items', [{ name: 'foo' }]); - equal( innerHTML(ul.getElementsByTagName('li')[0]), 'foo', 'updated observable'); + assert.equal( innerHTML(ul.getElementsByTagName('li')[0]), 'foo', 'updated observable'); }); - test("unescape bindings change", function () { + QUnit.test("unescape bindings change", function(assert) { var l = new DefineList([{ complete: true }, { @@ -1087,27 +1087,27 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled); var child = div.getElementsByTagName('div')[0]; - equal( innerHTML(child), "2", "at first there are 2 true bindings"); + assert.equal( innerHTML(child), "2", "at first there are 2 true bindings"); var item = new SimpleMap({ complete: true, id: "THIS ONE" }); l.push(item); - equal(innerHTML(child), "3", "now there are 3 complete"); + assert.equal(innerHTML(child), "3", "now there are 3 complete"); item.set('complete', false); - equal(innerHTML(child), "2", "now there are 2 complete"); + assert.equal(innerHTML(child), "2", "now there are 2 complete"); l.pop(); item.set('complete', true); - equal(innerHTML(child), "2", "there are still 2 complete"); + assert.equal(innerHTML(child), "2", "there are still 2 complete"); }); - test("escape bindings change", function () { + QUnit.test("escape bindings change", function(assert) { var l = new DefineList([{ complete: true }, { @@ -1136,20 +1136,20 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled); var child = div.getElementsByTagName('div')[0]; - equal(innerHTML(child), "2", "at first there are 2 true bindings"); + assert.equal(innerHTML(child), "2", "at first there are 2 true bindings"); var item = new SimpleMap({ complete: true }) l.push(item); - equal(innerHTML(child), "3", "now there are 3 complete"); + assert.equal(innerHTML(child), "3", "now there are 3 complete"); item.set('complete', false); - equal(innerHTML(child), "2", "now there are 2 complete"); + assert.equal(innerHTML(child), "2", "now there are 2 complete"); }); - test("tag bindings change", function () { + QUnit.test("tag bindings change", function(assert) { var l = new DefineList([{ complete: true }, { @@ -1178,20 +1178,20 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled); var child = div.getElementsByTagName('div')[0]; - equal(child.getAttribute("items"), "2", "at first there are 2 true bindings"); + assert.equal(child.getAttribute("items"), "2", "at first there are 2 true bindings"); var item = new SimpleMap({ complete: true }) l.push(item); - equal(child.getAttribute("items"), "3", "now there are 3 complete"); + assert.equal(child.getAttribute("items"), "3", "now there are 3 complete"); item.set('complete', false); - equal(child.getAttribute("items"), "2", "now there are 2 complete"); + assert.equal(child.getAttribute("items"), "2", "now there are 2 complete"); }) - test("attribute value bindings change", function () { + QUnit.test("attribute value bindings change", function(assert) { var l = new DefineList([{ complete: true }, { @@ -1220,20 +1220,20 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled); var child = div.getElementsByTagName('div')[0]; - equal(child.getAttribute("items"), "2", "at first there are 2 true bindings"); + assert.equal(child.getAttribute("items"), "2", "at first there are 2 true bindings"); var item = new SimpleMap({ complete: true }); l.push(item); - equal(child.getAttribute("items"), "3", "now there are 3 complete"); + assert.equal(child.getAttribute("items"), "3", "now there are 3 complete"); item.set('complete', false); - equal(child.getAttribute("items"), "2", "now there are 2 complete"); + assert.equal(child.getAttribute("items"), "2", "now there are 2 complete"); }); - test("in tag toggling", function () { + QUnit.test("in tag toggling", function(assert) { var text = "
                " var obs = new SimpleMap({ @@ -1252,12 +1252,12 @@ function makeTest(name, doc, mutation) { obs.set('val', 'foo="bar"') var d2 = div.getElementsByTagName('div')[0]; // toUpperCase added to normalize cases for IE8 - equal(d2.getAttribute("foo"), "bar", "bar set"); - equal(d2.getAttribute("bar"), null, "bar set") + assert.equal(d2.getAttribute("foo"), "bar", "bar set"); + assert.equal(d2.getAttribute("bar"), null, "bar set") }); // not sure about this w/ mustache - test("nested properties", function () { + QUnit.test("nested properties", function(assert) { var text = "
                {{ obs.name.first }}
                " @@ -1277,15 +1277,15 @@ function makeTest(name, doc, mutation) { div = div.getElementsByTagName('div')[0]; - equal(innerHTML(div), "Justin") + assert.equal(innerHTML(div), "Justin") obs.get('name').set('first', "Brian") - equal(innerHTML(div), "Brian") + assert.equal(innerHTML(div), "Brian") }); - test("tags without chidren or ending with /> do not change the state", function () { + QUnit.test("tags without chidren or ending with /> do not change the state", function(assert) { var text = "" var obs = new SimpleMap({ @@ -1298,14 +1298,14 @@ function makeTest(name, doc, mutation) { var html = compiled; div.appendChild(html); - equal(div.getElementsByTagName('span') + assert.equal(div.getElementsByTagName('span') .length, 0, "there are no spans"); - equal(div.getElementsByTagName('td') + assert.equal(div.getElementsByTagName('td') .length, 2, "there are 2 td"); }) - test("nested live bindings", function () { - expect(0); + QUnit.test("nested live bindings", function(assert) { + assert.expect(0); var items = new DefineList([{ title: 0, @@ -1331,7 +1331,7 @@ function makeTest(name, doc, mutation) { items[0].set('is_done', true); }); - test("list nested in observe live bindings", function () { + QUnit.test("list nested in observe live bindings", function(assert) { var template = stache("
                  {{#data.items}}
                • {{name}}
                • {{/data.items}}
                "); var data = new SimpleMap({ items: new DefineList([{ @@ -1347,20 +1347,20 @@ function makeTest(name, doc, mutation) { data.get("items").push(new SimpleMap({ name: "Scott" })) - ok(/Brian/.test(innerHTML(div)), "added first name") - ok(/Fara/.test(innerHTML(div)), "added 2nd name") - ok(/Scott/.test(innerHTML(div)), "added name after push") + assert.ok(/Brian/.test(innerHTML(div)), "added first name") + assert.ok(/Fara/.test(innerHTML(div)), "added 2nd name") + assert.ok(/Scott/.test(innerHTML(div)), "added name after push") }); - test("trailing text", function () { + QUnit.test("trailing text", function(assert) { var template = stache("There are {{ length }} todos") var div = doc.createElement('div'); div.appendChild(template(new DefineList([{}, {}]))); - ok(/There are 2 todos/.test(innerHTML(div)), "got all text"); + assert.ok(/There are 2 todos/.test(innerHTML(div)), "got all text"); }); if(isNormalDOM) { - test("recursive views", function () { + QUnit.test("recursive views", function(assert) { var template = stache('
                '+ '{{#items}}'+ '
                '+ @@ -1394,12 +1394,12 @@ function makeTest(name, doc, mutation) { }) div.appendChild(frag); - ok(/class="?leaf"?/.test(innerHTML(div)), "we have a leaf") + assert.ok(/class="?leaf"?/.test(innerHTML(div)), "we have a leaf") }); } - test("live binding textarea", function () { + QUnit.test("live binding textarea", function(assert) { var template = stache(""); var obs = new SimpleMap({ @@ -1412,18 +1412,18 @@ function makeTest(name, doc, mutation) { })); var textarea = div.firstChild; - equal(getValue(textarea), "BeforeyesAfter"); + assert.equal(getValue(textarea), "BeforeyesAfter"); obs.set("middle", "Middle"); - equal(getValue(textarea), "BeforeMiddleAfter"); + assert.equal(getValue(textarea), "BeforeMiddleAfter"); }); - QUnit.test("helper parameters don't convert functions", function () { + QUnit.test("helper parameters don't convert functions", function(assert) { stache.registerHelper('helperWithFn', function (fn) { - ok(typeof fn === "function", 'Parameter is a function'); - equal(fn(), 'Hit me!', 'Got the expected function'); + assert.ok(typeof fn === "function", 'Parameter is a function'); + assert.equal(fn(), 'Hit me!', 'Got the expected function'); }); var renderer = stache('{{helperWithFn test}}'); @@ -1434,10 +1434,10 @@ function makeTest(name, doc, mutation) { }); }) - QUnit.test("computes as helper parameters don't get converted", function () { + QUnit.test("computes as helper parameters don't get converted", function(assert) { stache.registerHelper('computeTest', function (no) { - equal(no(), 5, 'Got computed calue'); - ok(no.isComputed, 'no is still a compute') + assert.equal(no(), 5, 'Got computed calue'); + assert.ok(no.isComputed, 'no is still a compute') }); var renderer = stache('{{computeTest test}}'); @@ -1446,7 +1446,7 @@ function makeTest(name, doc, mutation) { }); }); - test("computes are supported in default helpers", function () { + QUnit.test("computes are supported in default helpers", function(assert) { var staches = { "if": "{{#if test}}if{{else}}else{{/if}}", @@ -1458,7 +1458,7 @@ function makeTest(name, doc, mutation) { var template = stache("There are {{ length }} todos"); var div = doc.createElement('div'); div.appendChild(template(new DefineList([{}, {}]))); - ok(/There are 2 todos/.test(innerHTML(div)), "got all text"); + assert.ok(/There are 2 todos/.test(innerHTML(div)), "got all text"); var renderer, result, data, actual, span; @@ -1477,7 +1477,7 @@ function makeTest(name, doc, mutation) { } actual = innerHTML(div); - equal(actual, result, "canCompute resolved for helper " + result); + assert.equal(actual, result, "canCompute resolved for helper " + result); } var inv_staches = { @@ -1497,13 +1497,13 @@ function makeTest(name, doc, mutation) { div.appendChild(actual); actual = innerHTML(div); - equal(actual, result, "canCompute resolved for helper " + result); + assert.equal(actual, result, "canCompute resolved for helper " + result); } }); //Issue 233 - test("multiple tbodies in table hookup", function () { + QUnit.test("multiple tbodies in table hookup", function(assert) { var text = "
                {{{ obs.content }}}
                " + "{{#people}}" + "" + @@ -1517,11 +1517,11 @@ function makeTest(name, doc, mutation) { compiled = stache(text)({ people: people }); - equal( compiled.firstChild.getElementsByTagName("tbody").length, 2, "two tbodies"); + assert.equal( compiled.firstChild.getElementsByTagName("tbody").length, 2, "two tbodies"); }); // http://forum.javascriptmvc.com/topic/live-binding-on-mustache-template-does-not-seem-to-be-working-with-nested-properties - test("Observe with array attributes", function () { + QUnit.test("Observe with array attributes", function(assert) { var renderer = stache('
                  {{#todos}}
                • {{.}}
                • {{/todos}}
                {{message}}
                '); var div = doc.createElement('div'); var data = new SimpleMap({ @@ -1531,17 +1531,17 @@ function makeTest(name, doc, mutation) { }); div.appendChild(renderer(data)); - equal(innerHTML(div.getElementsByTagName('li')[1]), 'Line #2', 'Check initial array'); - equal(innerHTML(div.getElementsByTagName('div')[0]), 'Hello', 'Check initial message'); + assert.equal(innerHTML(div.getElementsByTagName('li')[1]), 'Line #2', 'Check initial array'); + assert.equal(innerHTML(div.getElementsByTagName('div')[0]), 'Hello', 'Check initial message'); data.get('todos').set(1, 'Line #2 changed'); data.set('message', 'Hello again'); - equal(innerHTML(div.getElementsByTagName('li')[1]), 'Line #2 changed', 'Check updated array'); - equal(innerHTML(div.getElementsByTagName('div')[0]), 'Hello again', 'Check updated message'); + assert.equal(innerHTML(div.getElementsByTagName('li')[1]), 'Line #2 changed', 'Check updated array'); + assert.equal(innerHTML(div.getElementsByTagName('div')[0]), 'Hello again', 'Check updated message'); }); - test("Observe list returned from the function", function () { + QUnit.test("Observe list returned from the function", function(assert) { var renderer = stache('
                  {{#todos()}}
                • {{.}}
                • {{/todos}}
                '); var div = doc.createElement('div'); var todos = new DefineList(); @@ -1554,13 +1554,13 @@ function makeTest(name, doc, mutation) { todos.push("Todo #1") - equal(div.getElementsByTagName('li') + assert.equal(div.getElementsByTagName('li') .length, 1, 'Todo is successfuly created'); - equal(innerHTML(div.getElementsByTagName('li')[0]), 'Todo #1', 'Pushing to the list works'); + assert.equal(innerHTML(div.getElementsByTagName('li')[0]), 'Todo #1', 'Pushing to the list works'); }); // https://github.com/canjs/canjs/issues/228 - QUnit.test("Contexts within helpers not always resolved correctly", function () { + QUnit.test("Contexts within helpers not always resolved correctly", function(assert) { stache.registerHelper("bad_context", function (context, options) { return [""+this.text+" should not be ",options.fn(context)]; @@ -1578,13 +1578,13 @@ function makeTest(name, doc, mutation) { div.appendChild(renderer(data)); - equal(innerHTML(div.getElementsByTagName('span')[0]), "foo", 'Incorrect context passed to helper'); - equal(innerHTML(div.getElementsByTagName('span')[1]), "bar", 'Incorrect text in helper inner template'); - equal(innerHTML(div.getElementsByTagName('span')[2]), "In the inner context", 'Incorrect other_text in helper inner template'); + assert.equal(innerHTML(div.getElementsByTagName('span')[0]), "foo", 'Incorrect context passed to helper'); + assert.equal(innerHTML(div.getElementsByTagName('span')[1]), "bar", 'Incorrect text in helper inner template'); + assert.equal(innerHTML(div.getElementsByTagName('span')[2]), "In the inner context", 'Incorrect other_text in helper inner template'); }); // https://github.com/canjs/canjs/issues/227 - QUnit.test("Contexts are not always passed to partials properly", function () { + QUnit.test("Contexts are not always passed to partials properly", function(assert) { var inner = stache('{{#if ../other_first_level}}{{../other_first_level}}{{else}}{{second_level}}{{/if}}'); var renderer = stache('{{#first_level}}{{> inner}} should equal {{../other_first_level}}{{/first_level}}'), @@ -1597,12 +1597,12 @@ function makeTest(name, doc, mutation) { div = doc.createElement('div'); div.appendChild(renderer(data, {partials: {inner: inner}})); - equal(innerHTML(div.getElementsByTagName('span')[0]), "foo", 'Incorrect context passed to helper'); - equal(innerHTML(div.getElementsByTagName('span')[1]), "foo", 'Incorrect text in helper inner template'); + assert.equal(innerHTML(div.getElementsByTagName('span')[0]), "foo", 'Incorrect context passed to helper'); + assert.equal(innerHTML(div.getElementsByTagName('span')[1]), "foo", 'Incorrect text in helper inner template'); }); // https://github.com/canjs/canjs/issues/231 - QUnit.test("Functions and helpers should be passed the same context", function () { + QUnit.test("Functions and helpers should be passed the same context", function(assert) { var textNodes = function(el, cb) { var cur = el.firstChild; @@ -1637,11 +1637,11 @@ function makeTest(name, doc, mutation) { div.appendChild(renderer(data)); - equal(innerHTML(div.getElementsByTagName('span')[0]), data.next_level.other_text.toUpperCase(), 'correct context passed to helper'); + assert.equal(innerHTML(div.getElementsByTagName('span')[0]), data.next_level.other_text.toUpperCase(), 'correct context passed to helper'); }); // https://github.com/canjs/canjs/issues/153 - test("Interpolated values when iterating through an Observe.List should still render when not surrounded by a DOM node", function () { + QUnit.test("Interpolated values when iterating through an Observe.List should still render when not surrounded by a DOM node", function(assert) { var renderer = stache('{{ #todos }}{{ name }}{{ /todos }}'), renderer2 = stache('{{ #todos }}{{ name }}{{ /todos }}'), todos = [{ @@ -1661,33 +1661,33 @@ function makeTest(name, doc, mutation) { div.appendChild(renderer2(plainData)); - equal(innerHTML(div.getElementsByTagName('span')[0]), "Dishes", 'Array item rendered with DOM container'); - equal(innerHTML(div.getElementsByTagName('span')[1]), "Forks", 'Array item rendered with DOM container'); + assert.equal(innerHTML(div.getElementsByTagName('span')[0]), "Dishes", 'Array item rendered with DOM container'); + assert.equal(innerHTML(div.getElementsByTagName('span')[1]), "Forks", 'Array item rendered with DOM container'); div.innerHTML = ''; div.appendChild(renderer2(liveData)); - equal(innerHTML(div.getElementsByTagName('span')[0]), "Dishes", 'List item rendered with DOM container'); - equal(innerHTML(div.getElementsByTagName('span')[1]), "Forks", 'List item rendered with DOM container'); + assert.equal(innerHTML(div.getElementsByTagName('span')[0]), "Dishes", 'List item rendered with DOM container'); + assert.equal(innerHTML(div.getElementsByTagName('span')[1]), "Forks", 'List item rendered with DOM container'); div = doc.createElement('div'); div.appendChild(renderer(plainData)); - equal(innerHTML(div), "DishesForks", 'Array item rendered without DOM container'); + assert.equal(innerHTML(div), "DishesForks", 'Array item rendered without DOM container'); div = doc.createElement('div'); div.appendChild(renderer(liveData)); - equal(innerHTML(div), "DishesForks", 'List item rendered without DOM container'); + assert.equal(innerHTML(div), "DishesForks", 'List item rendered without DOM container'); liveData.todos.push({ id: 3, name: 'Knives' }); - equal(innerHTML(div), "DishesForksKnives", 'New list item rendered without DOM container'); + assert.equal(innerHTML(div), "DishesForksKnives", 'New list item rendered without DOM container'); }); - test("objects with a 'key' or 'index' property should work in helpers", function () { + QUnit.test("objects with a 'key' or 'index' property should work in helpers", function(assert) { var renderer = stache('{{ #obj }}{{ show_name(this) }}{{ /obj }}'), div = doc.createElement('div'); @@ -1702,7 +1702,7 @@ function makeTest(name, doc, mutation) { return obj.name; } })); - equal(innerHTML(div), "Forks", 'item name rendered'); + assert.equal(innerHTML(div), "Forks", 'item name rendered'); div = doc.createElement('div'); @@ -1717,10 +1717,10 @@ function makeTest(name, doc, mutation) { return obj.name; } })); - equal(innerHTML(div), "Forks", 'item name rendered'); + assert.equal(innerHTML(div), "Forks", 'item name rendered'); }); - test("2 way binding helpers", function () { + QUnit.test("2 way binding helpers", function(assert) { var Value = function (el, value) { this.updateElement = function (ev, newVal) { @@ -1756,16 +1756,16 @@ function makeTest(name, doc, mutation) { var input = div.getElementsByTagName('input')[0]; - equal(input.value, "Justin", "Name is set correctly") + assert.equal(input.value, "Justin", "Name is set correctly") u.set('name', 'Eli') - equal(input.value, "Eli", "Changing observe updates value"); + assert.equal(input.value, "Eli", "Changing observe updates value"); input.value = "Austin"; input.onchange(); - equal(u.get('name'), "Austin", "Name changed by input field"); + assert.equal(u.get('name'), "Austin", "Name changed by input field"); val.teardown(); @@ -1778,15 +1778,15 @@ function makeTest(name, doc, mutation) { })); input = div.getElementsByTagName('input')[0]; - equal(input.value, "", "Name is set correctly") + assert.equal(input.value, "", "Name is set correctly") u.set('name', 'Eli') - equal(input.value, "Eli", "Changing observe updates value"); + assert.equal(input.value, "Eli", "Changing observe updates value"); input.value = "Austin"; input.onchange(); - equal(u.get('name'), "Austin", "Name changed by input field"); + assert.equal(u.get('name'), "Austin", "Name changed by input field"); val.teardown(); // name is null @@ -1800,20 +1800,20 @@ function makeTest(name, doc, mutation) { })); input = div.getElementsByTagName('input')[0]; - equal(input.value, "", "Name is set correctly with null") + assert.equal(input.value, "", "Name is set correctly with null") u.set('name', 'Eli') - equal(input.value, "Eli", "Changing observe updates value"); + assert.equal(input.value, "Eli", "Changing observe updates value"); input.value = "Austin"; input.onchange(); - equal(u.get('name'), "Austin", "Name changed by input field"); + assert.equal(u.get('name'), "Austin", "Name changed by input field"); val.teardown(); }); - test("can pass in partials", function () { + QUnit.test("can pass in partials", function(assert) { var hello = stache("

                Hello {{> name}}

                "); var fancyName = stache("{{name}}"); @@ -1828,10 +1828,10 @@ function makeTest(name, doc, mutation) { - ok(/World/.test(innerHTML(result.firstChild)), "Hello World worked"); + assert.ok(/World/.test(innerHTML(result.firstChild)), "Hello World worked"); }); - test("can pass in helpers", function () { + QUnit.test("can pass in helpers", function(assert) { var helpers = stache("

                Hello {{cap name}}

                "); var result = helpers({ name: "world" @@ -1843,10 +1843,10 @@ function makeTest(name, doc, mutation) { } }); - ok(/World/.test(innerHTML(result.firstChild)), "Hello World worked"); + assert.ok(/World/.test(innerHTML(result.firstChild)), "Hello World worked"); }); - test("HTML comment with helper", function () { + QUnit.test("HTML comment with helper", function(assert) { var text = ["
                  ", "{{#todos}}", "
                • ", @@ -1881,8 +1881,8 @@ function makeTest(name, doc, mutation) { div.appendChild(compiled); li = div.getElementsByTagName("ul")[0].getElementsByTagName("li"); - equal(li.length, 1, "1 item in list"); - equal(comments(li[0]), 2, "2 comments in item #1"); + assert.equal(li.length, 1, "1 item in list"); + assert.equal(comments(li[0]), 2, "2 comments in item #1"); todos.push({ id: 2, @@ -1891,18 +1891,18 @@ function makeTest(name, doc, mutation) { li = div.getElementsByTagName("ul")[0].getElementsByTagName("li"); - equal(li.length, 2, "2 items in list"); - equal(comments(li[0]), 2, "2 comments in item #1"); - equal(comments(li[1]), 2, "2 comments in item #2"); + assert.equal(li.length, 2, "2 items in list"); + assert.equal(comments(li[0]), 2, "2 comments in item #1"); + assert.equal(comments(li[1]), 2, "2 comments in item #2"); todos.splice(0, 2); li = div.getElementsByTagName("ul")[0].getElementsByTagName("li"); - equal(li.length, 0, "0 items in list"); + assert.equal(li.length, 0, "0 items in list"); }); - test("Empty strings in arrays within Observes that are iterated should return blank strings", function () { + QUnit.test("Empty strings in arrays within Observes that are iterated should return blank strings", function(assert) { var data = new SimpleMap({ colors: ["", 'red', 'green', 'blue'] }), @@ -1910,10 +1910,10 @@ function makeTest(name, doc, mutation) { div = doc.createElement('div'); div.appendChild(compiled); - equal(innerHTML(div.getElementsByTagName('option')[0]), "", "Blank string should return blank"); + assert.equal(innerHTML(div.getElementsByTagName('option')[0]), "", "Blank string should return blank"); }); - test("Null properties do not throw errors", function () { + QUnit.test("Null properties do not throw errors", function(assert) { var renderer = stache("Foo bar {{#foo.bar}}exists{{/foo.bar}}{{^foo.bar}}does not exist{{/foo.bar}}"), div = doc.createElement('div'), div2 = doc.createElement('div'), @@ -1924,7 +1924,7 @@ function makeTest(name, doc, mutation) { foo: null })); } catch (e) { - ok(false, "rendering with null threw an error"); + assert.ok(false, "rendering with null threw an error"); } frag2 = renderer(new SimpleMap({ foo: { @@ -1933,12 +1933,12 @@ function makeTest(name, doc, mutation) { })); div.appendChild(frag); div2.appendChild(frag2); - equal(innerHTML(div), "Foo bar does not exist"); - equal(innerHTML(div2), "Foo bar exists"); + assert.equal(innerHTML(div), "Foo bar does not exist"); + assert.equal(innerHTML(div2), "Foo bar exists"); }); // Issue #288 - test("Data helper should set proper data instead of a context stack", function () { + QUnit.test("Data helper should set proper data instead of a context stack", function(assert) { var partials = { 'nested_data': stache(''), 'nested_data2': stache('{{#this}}{{/this}}'), @@ -1959,20 +1959,20 @@ function makeTest(name, doc, mutation) { div.appendChild(renderer(data,{partials: partials})); span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 1 should have correct data'); + assert.strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 1 should have correct data'); div = doc.createElement('div'); div.appendChild(renderer2(data,{partials: partials})); span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 2 should have correct data'); + assert.strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 2 should have correct data'); div = doc.createElement('div'); div.appendChild(renderer3(data,{partials: partials})); span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 3 should have correct data'); + assert.strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 3 should have correct data'); }); - test("domData helper should set proper data instead of a context stack", function () { + QUnit.test("domData helper should set proper data instead of a context stack", function(assert) { var partials = { 'nested_data': stache(''), 'nested_data2': stache('{{#this}}{{/this}}'), @@ -1993,20 +1993,20 @@ function makeTest(name, doc, mutation) { div.appendChild(renderer(data,{partials: partials})); span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 1 should have correct data'); + assert.strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 1 should have correct data'); div = doc.createElement('div'); div.appendChild(renderer2(data,{partials: partials})); span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 2 should have correct data'); + assert.strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 2 should have correct data'); div = doc.createElement('div'); div.appendChild(renderer3(data,{partials: partials})); span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 3 should have correct data'); + assert.strictEqual(domData.get(span, 'attr'), data.get('bar'), 'Nested data 3 should have correct data'); }); - test("data helper should store passed values", function () { + QUnit.test("data helper should store passed values", function(assert) { var template = ""; var vm = new DefineMap({ todos: [ @@ -2020,10 +2020,10 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(rendered); var span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'todo'), vm.todos[0], 'can-dom-data-state should have the correct value'); + assert.strictEqual(domData.get(span, 'todo'), vm.todos[0], 'can-dom-data-state should have the correct value'); }); - test("domData helper should store passed values", function () { + QUnit.test("domData helper should store passed values", function(assert) { var template = ""; var vm = new DefineMap({ todos: [ @@ -2037,10 +2037,10 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(rendered); var span = div.getElementsByTagName('span')[0]; - strictEqual(domData.get(span, 'todo'), vm.todos[0], 'can-dom-data should have the correct value'); + assert.strictEqual(domData.get(span, 'todo'), vm.todos[0], 'can-dom-data should have the correct value'); }); - test("avoid global helpers", function () { + QUnit.test("avoid global helpers", function(assert) { var noglobals = stache("{{sometext person.name}}"); var div = doc.createElement('div'), @@ -2070,11 +2070,11 @@ function makeTest(name, doc, mutation) { person.set("name", "Ajax") - equal(innerHTML(div), "Mr. Ajax"); - equal(innerHTML(div2), "Ajax rules"); + assert.equal(innerHTML(div), "Mr. Ajax"); + assert.equal(innerHTML(div2), "Ajax rules"); }); - QUnit.test("scope functions should have priority over local helpers over global helpers", function() { + QUnit.test("scope functions should have priority over local helpers over global helpers", function(assert) { stache.addHelper('help', function() { return 'global'; }); /* @@ -2089,7 +2089,7 @@ function makeTest(name, doc, mutation) { } ); - QUnit.equal(result, 'scope', 'scope function, local, global - uses scope'); + assert.equal(result, 'scope', 'scope function, local, global - uses scope'); /* * if there is a function on the scope and a global helper @@ -2101,7 +2101,7 @@ function makeTest(name, doc, mutation) { help: function() { return 'local'; } } ); - QUnit.equal(result, 'local', 'local, global - uses local'); + assert.equal(result, 'local', 'local, global - uses local'); /* * if there is only a global helper @@ -2110,12 +2110,12 @@ function makeTest(name, doc, mutation) { result = getText( '{{help()}}' ); - QUnit.equal(result, 'global', 'global - uses global'); + assert.equal(result, 'global', 'global - uses global'); }); - test("Each does not redraw items", function () { + QUnit.test("Each does not redraw items", function(assert) { var animals = new DefineList(['sloth', 'bear']), renderer = stache("
                  myfavoriteanimals:{{#each animals}} {{this}}{{/}}!
                  "); @@ -2130,18 +2130,18 @@ function makeTest(name, doc, mutation) { div.getElementsByTagName('label')[0].myexpando = "EXPANDO-ED"; //animals.push("dog") - equal(div.getElementsByTagName('label') + assert.equal(div.getElementsByTagName('label') .length, 2, "There are 2 labels"); animals.push("turtle") - equal(div.getElementsByTagName('label')[0].myexpando, "EXPANDO-ED", "same expando"); + assert.equal(div.getElementsByTagName('label')[0].myexpando, "EXPANDO-ED", "same expando"); - equal(innerHTML(div.getElementsByTagName('span')[2]), "turtle", "turtle added"); + assert.equal(innerHTML(div.getElementsByTagName('span')[2]), "turtle", "turtle added"); }); - test("Each works with the empty list", function () { + QUnit.test("Each works with the empty list", function(assert) { var animals = new DefineList([]), renderer = stache("
                  myfavoriteanimals:{{#each animals}} {{this}}{{/}}!
                  "); @@ -2156,7 +2156,7 @@ function makeTest(name, doc, mutation) { animals.push('sloth', 'bear') //animals.push("dog") - equal(div.getElementsByTagName('label') + assert.equal(div.getElementsByTagName('label') .length, 2, "There are 2 labels") //animals.push("turtle") @@ -2165,7 +2165,7 @@ function makeTest(name, doc, mutation) { }); - test("each works within another branch", function () { + QUnit.test("each works within another branch", function(assert) { var animals = new DefineList(['sloth']), template = "
                  Animals:" + "{{#if animals.length}}~" + @@ -2186,18 +2186,18 @@ function makeTest(name, doc, mutation) { }); div.appendChild(frag); - equal(div.getElementsByTagName('span') + assert.equal(div.getElementsByTagName('span') .length, 1, "There is 1 sloth"); animals.pop(); - equal(innerHTML(div.getElementsByTagName('div')[0]), "Animals:No animals!"); + assert.equal(innerHTML(div.getElementsByTagName('div')[0]), "Animals:No animals!"); }); - test("a compute gets passed to a plugin", function () { + QUnit.test("a compute gets passed to a plugin", function(assert) { stache.registerHelper('iamhungryforcomputes', function (value) { - ok(value.isComputed, "value is a compute") + assert.ok(value.isComputed, "value is a compute") return function (el) { } @@ -2219,7 +2219,7 @@ function makeTest(name, doc, mutation) { }); // CHANGED FROM MUSTACHE - test("Object references can escape periods for key names containing periods", function () { + QUnit.test("Object references can escape periods for key names containing periods", function(assert) { var template = stache("{{#foo.bar}}" + "{{some\\.key\\.name}} {{some\\.other\\.key.with\\.more}}" + "{{/foo.bar}}"), @@ -2237,10 +2237,10 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(template(data)) - equal(innerHTML(div), "100 values"); + assert.equal(innerHTML(div), "100 values"); }); - test("Computes should be resolved prior to accessing attributes", function () { + QUnit.test("Computes should be resolved prior to accessing attributes", function(assert) { var template = stache("{{list.length}}"), data = { list: new SimpleObservable(new DefineList()) @@ -2249,10 +2249,10 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(template(data)) - equal(innerHTML(div), "0"); + assert.equal(innerHTML(div), "0"); }) - test("Helpers can be passed . or this for the active context", function () { + QUnit.test("Helpers can be passed . or this for the active context", function(assert) { stache.registerHelper('rsvp', function (attendee, event) { return attendee.name + ' is attending ' + event.name; }); @@ -2272,17 +2272,17 @@ function makeTest(name, doc, mutation) { div.appendChild(template(data)); var children = div.getElementsByTagName('div'); - equal(innerHTML(children[0]), 'Justin is attending Reception'); - equal(innerHTML(children[1]), 'Justin is attending Wedding'); + assert.equal(innerHTML(children[0]), 'Justin is attending Reception'); + assert.equal(innerHTML(children[1]), 'Justin is attending Wedding'); }); - test("helpers only called once (#477)", function () { + QUnit.test("helpers only called once (#477)", function(assert) { var callCount = 0; stache.registerHelper("foo", function (text) { callCount++; - equal(callCount, 1, "call count is only ever one") + assert.equal(callCount, 1, "call count is only ever one") return "result"; }); @@ -2298,11 +2298,11 @@ function makeTest(name, doc, mutation) { }); - test("helpers between tags (#469)", function () { + QUnit.test("helpers between tags (#469)", function(assert) { stache.registerHelper("itemsHelper", function () { return function (textNode) { - equal(textNode.nodeType, 3, "right nodeType") + assert.equal(textNode.nodeType, 3, "right nodeType") }; }); @@ -2310,7 +2310,7 @@ function makeTest(name, doc, mutation) { template(); }); - test("hiding image srcs (#157)", function () { + QUnit.test("hiding image srcs (#157)", function(assert) { var template = stache('An image'), data = new SimpleMap({ image: null @@ -2320,15 +2320,15 @@ function makeTest(name, doc, mutation) { var frag = template(data), img = frag.firstChild; - equal(img.getAttribute("src"), null, "there is no src"); + assert.equal(img.getAttribute("src"), null, "there is no src"); data.set("image", url); - notEqual(img.getAttribute("src"), null, 'Image should have src'); - equal(img.getAttribute("src"), url, "images src is correct"); + assert.notEqual(img.getAttribute("src"), null, 'Image should have src'); + assert.equal(img.getAttribute("src"), url, "images src is correct"); }); - test("live binding in a truthy section", function () { + QUnit.test("live binding in a truthy section", function(assert) { var template = stache('
                  '), data = new SimpleMap({ width: '100' @@ -2337,14 +2337,14 @@ function makeTest(name, doc, mutation) { var frag = template(data), img = frag.firstChild; - equal(img.getAttribute("width"), "100", "initial width is correct"); + assert.equal(img.getAttribute("width"), "100", "initial width is correct"); data.set("width", "300"); - equal(img.getAttribute('width'), "300", "updated width is correct"); + assert.equal(img.getAttribute('width'), "300", "updated width is correct"); }); - test("backtracks in mustache (#163)", function () { + QUnit.test("backtracks in mustache (#163)", function(assert) { var template = stache( "{{#grid.rows}}" + @@ -2377,29 +2377,29 @@ function makeTest(name, doc, mutation) { }); var divs = getChildNodes(frag); - equal(divs.length, 4, "there are 4 divs"); + assert.equal(divs.length, 4, "there are 4 divs"); var vals = canReflect.toArray(divs).map(function (div) { return innerHTML(div); }); - deepEqual(vals, ["Justin", "Meyer", "Brian", "Moschel"], "div values are the same"); + assert.deepEqual(vals, ["Justin", "Meyer", "Brian", "Moschel"], "div values are the same"); }); - test("support null and undefined as an argument", function () { + QUnit.test("support null and undefined as an argument", function(assert) { var template = stache("{{aHelper null undefined}}") template({}, { aHelper: function (arg1, arg2) { - ok(arg1 === null); - ok(arg2 === undefined) + assert.ok(arg1 === null); + assert.ok(arg2 === undefined) } }); }); - test("passing DefineList to helper (#438)", function () { + QUnit.test("passing DefineList to helper (#438)", function(assert) { var renderer = stache('
                  • observeList broken
                  • ' + '
                  • plain arrays work
                  '); @@ -2428,11 +2428,11 @@ function makeTest(name, doc, mutation) { var ul = div.firstChild; - equal(innerHTML( ul.childNodes.item(0)), 'Helper called', 'Helper called'); - equal(innerHTML( ul.childNodes.item(1)), 'Helper called', 'Helper called'); + assert.equal(innerHTML( ul.childNodes.item(0)), 'Helper called', 'Helper called'); + assert.equal(innerHTML( ul.childNodes.item(1)), 'Helper called', 'Helper called'); }); - test("hiding image srcs (#494)", function () { + QUnit.test("hiding image srcs (#494)", function(assert) { var template = stache(''), data = new SimpleMap({ image: "" @@ -2442,15 +2442,15 @@ function makeTest(name, doc, mutation) { var frag = template(data), img = frag.firstChild; - equal(img.getAttribute("src"), "", "the src is empty"); + assert.equal(img.getAttribute("src"), "", "the src is empty"); data.set("image", url); - notEqual(img.getAttribute("src"), "", 'Image should have src'); - equal(img.getAttribute("src"), url, "images src is correct"); + assert.notEqual(img.getAttribute("src"), "", 'Image should have src'); + assert.equal(img.getAttribute("src"), url, "images src is correct"); }); - test("hiding image srcs with complex content (#494)", function () { + QUnit.test("hiding image srcs with complex content (#494)", function(assert) { var template = stache(''), data = new SimpleMap({}), imgData = { @@ -2463,14 +2463,14 @@ function makeTest(name, doc, mutation) { var frag = template(data), img = frag.firstChild; - equal(img.getAttribute("src"), "", "the src is empty"); + assert.equal(img.getAttribute("src"), "", "the src is empty"); data.set("image", imgData); - notEqual(img.getAttribute("src"), "", 'Image should have src'); - equal(img.getAttribute("src"), url, "images src is correct"); + assert.notEqual(img.getAttribute("src"), "", 'Image should have src'); + assert.equal(img.getAttribute("src"), url, "images src is correct"); }); - test("empty lists update", 2, function () { + QUnit.test("empty lists update", 2, function(assert) { var template = stache('

                  {{#list}}{{.}}{{/list}}

                  '); var map = new SimpleMap({ list: ['something'] @@ -2481,12 +2481,12 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - equal(innerHTML( div.childNodes.item(0)), 'something', 'initial list content set'); + assert.equal(innerHTML( div.childNodes.item(0)), 'something', 'initial list content set'); map.set('list', ['one', 'two']); - equal(innerHTML( div.childNodes.item(0)), 'onetwo', 'updated list content set'); + assert.equal(innerHTML( div.childNodes.item(0)), 'onetwo', 'updated list content set'); }); - test("attributes in truthy section", function () { + QUnit.test("attributes in truthy section", function(assert) { var template = stache('

                  '); var data1 = { attribute: "test-value" @@ -2495,7 +2495,7 @@ function makeTest(name, doc, mutation) { var div1 = doc.createElement('div'); div1.appendChild(frag1); - equal(div1.childNodes.item(0).getAttribute('data-test'), 'test-value', 'hyphenated attribute value'); + assert.equal(div1.childNodes.item(0).getAttribute('data-test'), 'test-value', 'hyphenated attribute value'); var data2 = { attribute: "test value" @@ -2504,10 +2504,10 @@ function makeTest(name, doc, mutation) { var div2 = doc.createElement('div'); div2.appendChild(frag2); - equal(div2.childNodes.item(0).getAttribute('data-test'), 'test value', 'whitespace in attribute value'); + assert.equal(div2.childNodes.item(0).getAttribute('data-test'), 'test value', 'whitespace in attribute value'); }); - test("live bound attributes with no '='", function () { + QUnit.test("live bound attributes with no '='", function(assert) { var template = stache(''); var data = new SimpleMap({ selected: false @@ -2517,13 +2517,13 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); data.set('selected', true); - equal(div.childNodes.item(0).checked, true, 'hyphenated attribute value'); + assert.equal(div.childNodes.item(0).checked, true, 'hyphenated attribute value'); data.set("selected", false) - equal(div.childNodes.item(0).checked, false, 'hyphenated attribute value'); + assert.equal(div.childNodes.item(0).checked, false, 'hyphenated attribute value'); }); - test("outputting array of attributes", function () { + QUnit.test("outputting array of attributes", function(assert) { var template = stache('

                  '); var data = { attribute: [{ @@ -2541,12 +2541,12 @@ function makeTest(name, doc, mutation) { var div = doc.createElement('div'); div.appendChild(frag); - equal(div.childNodes.item(0).getAttribute('data-test1'), 'value1', 'first value'); - equal(div.childNodes.item(0).getAttribute('data-test2'), 'value2', 'second value'); - equal(div.childNodes.item(0).getAttribute('data-test3'), 'value3', 'third value'); + assert.equal(div.childNodes.item(0).getAttribute('data-test1'), 'value1', 'first value'); + assert.equal(div.childNodes.item(0).getAttribute('data-test2'), 'value2', 'second value'); + assert.equal(div.childNodes.item(0).getAttribute('data-test3'), 'value3', 'third value'); }); - test("incremental updating of #each within an if", function () { + QUnit.test("incremental updating of #each within an if", function(assert) { var template = stache('{{#if items.length}}
                    {{#each items}}
                  • {{/each}}
                  {{/if}}'); var items = new DefineList([{}, {}]); @@ -2559,11 +2559,11 @@ function makeTest(name, doc, mutation) { ul.setAttribute("original", "yup"); items.push({}); - ok(ul === div.getElementsByTagName('ul')[0], "ul is still the same") + assert.ok(ul === div.getElementsByTagName('ul')[0], "ul is still the same") }); - test("stache.safeString", function () { + QUnit.test("stache.safeString", function(assert) { var text = "Google", url = "http://google.com/", templateEscape = stache('{{link "' + text + '" "' + url + '"}}'), @@ -2578,20 +2578,20 @@ function makeTest(name, doc, mutation) { var frag = templateEscape({}); div.appendChild(frag); - equal(getChildNodes(div).length, 1, 'rendered a DOM node'); - equal(div.childNodes.item(0).nodeName, 'A', 'rendered an anchor tag'); - equal(innerHTML(div.childNodes.item(0)), text, 'rendered the text properly'); - equal(div.childNodes.item(0).getAttribute('href'), url, 'rendered the href properly'); + assert.equal(getChildNodes(div).length, 1, 'rendered a DOM node'); + assert.equal(div.childNodes.item(0).nodeName, 'A', 'rendered an anchor tag'); + assert.equal(innerHTML(div.childNodes.item(0)), text, 'rendered the text properly'); + assert.equal(div.childNodes.item(0).getAttribute('href'), url, 'rendered the href properly'); div = doc.createElement('div'); div.appendChild(templateUnescape({})); - equal(getChildNodes(div).length, 1, 'rendered a DOM node'); - equal(div.childNodes.item(0).nodeName, 'A', 'rendered an anchor tag'); - equal(innerHTML(div.childNodes.item(0)), text, 'rendered the text properly'); - equal(div.childNodes.item(0).getAttribute('href'), url, 'rendered the href properly'); + assert.equal(getChildNodes(div).length, 1, 'rendered a DOM node'); + assert.equal(div.childNodes.item(0).nodeName, 'A', 'rendered an anchor tag'); + assert.equal(innerHTML(div.childNodes.item(0)), text, 'rendered the text properly'); + assert.equal(div.childNodes.item(0).getAttribute('href'), url, 'rendered the href properly'); }); - test("nested properties binding (#525)", function () { + QUnit.test("nested properties binding (#525)", function(assert) { var template = stache(""); var me = new SimpleMap(); @@ -2601,12 +2601,12 @@ function makeTest(name, doc, mutation) { me.set("name", { first: "Justin" }); - equal(innerHTML(label), "Justin", "set name object"); + assert.equal(innerHTML(label), "Justin", "set name object"); me.set("name", { first: "Brian" }); - equal(innerHTML(label), "Brian", "merged name object"); + assert.equal(innerHTML(label), "Brian", "merged name object"); me.set("name",undefined); me.set({ @@ -2615,11 +2615,11 @@ function makeTest(name, doc, mutation) { } }); - equal(innerHTML(label), "Payal", "works after parent removed"); + assert.equal(innerHTML(label), "Payal", "works after parent removed"); }); - test("Rendering indices of an array with scope.index", function () { + QUnit.test("Rendering indices of an array with scope.index", function(assert) { var template = stache("
                    {{#each list}}
                  • {{scope.index}} {{.}}
                  • {{/each}}
                  "); var list = [0, 1, 2, 3]; @@ -2629,11 +2629,11 @@ function makeTest(name, doc, mutation) { .firstChild.getElementsByTagName('li'); for (var i = 0; i < lis.length; i++) { - equal(innerHTML(lis[i]), (i + ' ' + i), 'rendered index and value are correct'); + assert.equal(innerHTML(lis[i]), (i + ' ' + i), 'rendered index and value are correct'); } }); - test("Rendering indices of an array with @index + offset (#1078)", function () { + QUnit.test("Rendering indices of an array with @index + offset (#1078)", function(assert) { var template = stache("
                    {{#each list}}
                  • {{@index 5}} {{.}}
                  • {{/each}}
                  "); var list = [0, 1, 2, 3]; @@ -2643,11 +2643,11 @@ function makeTest(name, doc, mutation) { .firstChild.getElementsByTagName('li'); for (var i = 0; i < lis.length; i++) { - equal(innerHTML(lis[i]), (i+5 + ' ' + i), 'rendered index and value are correct'); + assert.equal(innerHTML(lis[i]), (i+5 + ' ' + i), 'rendered index and value are correct'); } }); - test("Passing indices into helpers as values", function () { + QUnit.test("Passing indices into helpers as values", function(assert) { var template = stache("
                    {{#each list}}
                  • {{test scope.index}} {{.}}
                  • {{/each}}
                  "); var list = [0, 1, 2, 3]; @@ -2660,11 +2660,11 @@ function makeTest(name, doc, mutation) { }).firstChild.getElementsByTagName('li'); for (var i = 0; i < lis.length; i++) { - equal(innerHTML(lis[i]), (i + ' ' + i), 'rendered index and value are correct'); + assert.equal(innerHTML(lis[i]), (i + ' ' + i), 'rendered index and value are correct'); } }); - test("Rendering live bound indices with #each, scope.index and a simple DefineList", function () { + QUnit.test("Rendering live bound indices with #each, scope.index and a simple DefineList", function(assert) { var list = new DefineList(['a', 'b', 'c']); var template = stache("
                    {{#each list}}
                  • {{scope.index}} {{.}}
                  • {{/each}}
                  "); @@ -2674,43 +2674,43 @@ function makeTest(name, doc, mutation) { //.getElementsByTagName('li'); var lis = tpl.getElementsByTagName('li'); - equal(lis.length, 3, "three lis"); + assert.equal(lis.length, 3, "three lis"); - equal(innerHTML(lis[0]), '0 a', "first index and value are correct"); - equal(innerHTML(lis[1]), '1 b', "second index and value are correct"); - equal(innerHTML(lis[2]), '2 c', "third index and value are correct"); + assert.equal(innerHTML(lis[0]), '0 a', "first index and value are correct"); + assert.equal(innerHTML(lis[1]), '1 b', "second index and value are correct"); + assert.equal(innerHTML(lis[2]), '2 c', "third index and value are correct"); // add a few more items list.push('d', 'e'); lis = tpl.getElementsByTagName('li'); - equal(lis.length, 5, "five lis"); + assert.equal(lis.length, 5, "five lis"); - equal(innerHTML(lis[3]), '3 d', "fourth index and value are correct"); - equal(innerHTML(lis[4]), '4 e', "fifth index and value are correct"); + assert.equal(innerHTML(lis[3]), '3 d', "fourth index and value are correct"); + assert.equal(innerHTML(lis[4]), '4 e', "fifth index and value are correct"); // splice off a few items and add some more list.splice(0, 2, 'z', 'y'); lis = tpl.getElementsByTagName('li'); - equal(lis.length, 5, "five lis"); - equal(innerHTML(lis[0]), '0 z', "first item updated"); - equal(innerHTML(lis[1]), '1 y', "second item updated"); - equal(innerHTML(lis[2]), '2 c', "third item the same"); - equal(innerHTML(lis[3]), '3 d', "fourth item the same"); - equal(innerHTML(lis[4]), '4 e', "fifth item the same"); + assert.equal(lis.length, 5, "five lis"); + assert.equal(innerHTML(lis[0]), '0 z', "first item updated"); + assert.equal(innerHTML(lis[1]), '1 y', "second item updated"); + assert.equal(innerHTML(lis[2]), '2 c', "third item the same"); + assert.equal(innerHTML(lis[3]), '3 d', "fourth item the same"); + assert.equal(innerHTML(lis[4]), '4 e', "fifth item the same"); // splice off from the middle list.splice(2, 2); lis = tpl.getElementsByTagName('li'); - equal(lis.length, 3, "three lis"); - equal(innerHTML(lis[0]), '0 z', "first item the same"); - equal(innerHTML(lis[1]), '1 y', "second item the same"); - equal(innerHTML(lis[2]), '2 e', "fifth item now the 3rd item"); + assert.equal(lis.length, 3, "three lis"); + assert.equal(innerHTML(lis[0]), '0 z', "first item the same"); + assert.equal(innerHTML(lis[1]), '1 y', "second item the same"); + assert.equal(innerHTML(lis[2]), '2 e', "fifth item now the 3rd item"); }); - test('Rendering keys of an object with #each and scope.key', function () { + QUnit.test('Rendering keys of an object with #each and scope.key', function(assert) { var template = stache("
                    {{#each obj}}
                  • {{scope.key}} {{.}}
                  • {{/each}}
                  "); var obj = { foo: 'string', @@ -2723,14 +2723,14 @@ function makeTest(name, doc, mutation) { }) .firstChild.getElementsByTagName('li'); - equal(lis.length, 3, "three lis"); + assert.equal(lis.length, 3, "three lis"); - equal(innerHTML(lis[0]), 'foo string', "first key value pair rendered"); - equal(innerHTML(lis[1]), 'bar 1', "second key value pair rendered"); - equal(innerHTML(lis[2]), 'baz false', "third key value pair rendered"); + assert.equal(innerHTML(lis[0]), 'foo string', "first key value pair rendered"); + assert.equal(innerHTML(lis[1]), 'bar 1', "second key value pair rendered"); + assert.equal(innerHTML(lis[2]), 'baz false', "third key value pair rendered"); }); - test('Live bound iteration of keys of a SimpleMap with #each and scope.key', function () { + QUnit.test('Live bound iteration of keys of a SimpleMap with #each and scope.key', function(assert) { // delete stache._helpers.foo; var template = stache("
                    {{#each map}}
                  • {{scope.key}} {{.}}
                  • {{/each}}
                  "); var map = new SimpleMap({ @@ -2744,32 +2744,32 @@ function makeTest(name, doc, mutation) { }); var lis = tpl.firstChild.getElementsByTagName('li'); - equal(lis.length, 3, "three lis"); + assert.equal(lis.length, 3, "three lis"); - equal(innerHTML(lis[0]), 'foo string', "first key value pair rendered"); - equal(innerHTML(lis[1]), 'bar 1', "second key value pair rendered"); - equal(innerHTML(lis[2]), 'baz false', "third key value pair rendered"); + assert.equal(innerHTML(lis[0]), 'foo string', "first key value pair rendered"); + assert.equal(innerHTML(lis[1]), 'bar 1', "second key value pair rendered"); + assert.equal(innerHTML(lis[2]), 'baz false', "third key value pair rendered"); map.set('qux', true); lis = tpl.firstChild.getElementsByTagName('li'); - equal(lis.length, 4, "four lis"); + assert.equal(lis.length, 4, "four lis"); - equal(innerHTML(lis[3]), 'qux true', "fourth key value pair rendered"); + assert.equal(innerHTML(lis[3]), 'qux true', "fourth key value pair rendered"); // A hack b/c map can't delete keys delete map._data.foo; map.dispatch("can.keys") lis = tpl.firstChild.getElementsByTagName('li'); - equal(lis.length, 3, "three lis"); + assert.equal(lis.length, 3, "three lis"); - equal(innerHTML(lis[0]), 'bar 1', "new first key value pair rendered"); - equal(innerHTML(lis[1]), 'baz false', "new second key value pair rendered"); - equal(innerHTML(lis[2]), 'qux true', "new third key value pair rendered"); + assert.equal(innerHTML(lis[0]), 'bar 1', "new first key value pair rendered"); + assert.equal(innerHTML(lis[1]), 'baz false', "new second key value pair rendered"); + assert.equal(innerHTML(lis[2]), 'qux true', "new third key value pair rendered"); }); - test('Make sure data passed into template does not call helper by mistake', function () { + QUnit.test('Make sure data passed into template does not call helper by mistake', function(assert) { var template = stache("

                  {{text}}

                  "); var data = { text: 'with' @@ -2778,10 +2778,10 @@ function makeTest(name, doc, mutation) { var h1 = template(data) .firstChild; - equal(innerHTML(h1), "with"); + assert.equal(innerHTML(h1), "with"); }); - test("no memory leaks with #each (#545)", function () { + QUnit.test("no memory leaks with #each (#545)", function(assert) { var tmp = stache("
                    {{#each children}}
                  • {{/each}}
                  "); var data = new SimpleMap({ @@ -2799,7 +2799,7 @@ function makeTest(name, doc, mutation) { domMutateNode.appendChild.call(div, tmp(data)); - stop(); + var done = assert.async(); setTimeout(function(){ domMutateNode.removeChild.call(div, div.firstChild); var check = function(){ @@ -2807,15 +2807,15 @@ function makeTest(name, doc, mutation) { if(handlers.length) { setTimeout(check, 20); } else { - QUnit.ok(true,"no handlers"); - QUnit.start(); + assert.ok(true,"no handlers"); + done(); } } check(); },10); }); - test("each directly within live html section", function () { + QUnit.test("each directly within live html section", function(assert) { var tmp = stache( "
                    {{#if showing}}" + "{{#each items}}
                  • item
                  • {{/each}}" + @@ -2837,12 +2837,12 @@ function makeTest(name, doc, mutation) { items.push("a"); - equal(frag.firstChild.getElementsByTagName("li") + assert.equal(frag.firstChild.getElementsByTagName("li") .length, 3, "there are 3 elements - "+frag.firstChild.innerHTML); }); - test("mustache loops with 0 (#568)", function () { + QUnit.test("mustache loops with 0 (#568)", function(assert) { var tmp = stache("
                      {{#array}}
                    • {{.}}
                    • {{/array}}"); @@ -2852,12 +2852,12 @@ function makeTest(name, doc, mutation) { var frag = tmp(data); - equal(innerHTML(frag.firstChild.getElementsByTagName("li")[0]), "0"); - equal(innerHTML(frag.firstChild.getElementsByTagName("li")[1]), ""); + assert.equal(innerHTML(frag.firstChild.getElementsByTagName("li")[0]), "0"); + assert.equal(innerHTML(frag.firstChild.getElementsByTagName("li")[1]), ""); }); - test('scope.index is correctly calculated when there are identical elements in the array', function () { + QUnit.test('scope.index is correctly calculated when there are identical elements in the array', function(assert) { var data = new DefineList(['foo', 'bar', 'baz', 'qux', 'foo']); var tmp = stache('{{#each data}}{{scope.index}} {{/each}}'); @@ -2867,10 +2867,10 @@ function makeTest(name, doc, mutation) { }); div.appendChild(frag); - equal(innerHTML(div), '0 1 2 3 4 '); + assert.equal(innerHTML(div), '0 1 2 3 4 '); }); - test("if helper within className (#592)", function () { + QUnit.test("if helper within className (#592)", function(assert) { var tmp = stache('
                      '); var data = new SimpleMap({ @@ -2878,7 +2878,7 @@ function makeTest(name, doc, mutation) { }); var frag = tmp(data); - equal(frag.firstChild.className, "fails animate-ready"); + assert.equal(frag.firstChild.className, "fails animate-ready"); tmp = stache('
                      '); data = new SimpleMap({ @@ -2886,10 +2886,10 @@ function makeTest(name, doc, mutation) { }); tmp(data); - equal(frag.firstChild.className, "fails animate-ready") + assert.equal(frag.firstChild.className, "fails animate-ready") }); - test('html comments must not break mustache scanner', function () { + QUnit.test('html comments must not break mustache scanner', function(assert) { canReflect.each([ 'text', 'text', @@ -2898,11 +2898,11 @@ function makeTest(name, doc, mutation) { ], function (content) { var div = doc.createElement('div'); div.appendChild(stache(content)()); - equal(innerHTML(div), content, 'Content did not change: "' + content + '"'); + assert.equal(innerHTML(div), content, 'Content did not change: "' + content + '"'); }); }); - test("Rendering live bound indices with #each, scope.index and a simple CanList when remove first item (#613)", function () { + QUnit.test("Rendering live bound indices with #each, scope.index and a simple CanList when remove first item (#613)", function(assert) { var list = new DefineList(['a', 'b', 'c']); var template = stache("
                        {{#each list}}
                      • {{scope.index}} {{.}}
                      • {{/each}}
                      "); @@ -2913,13 +2913,13 @@ function makeTest(name, doc, mutation) { // remove first item list.shift(); var lis = tpl.firstChild.getElementsByTagName('li'); - equal(lis.length, 2, "two lis"); + assert.equal(lis.length, 2, "two lis"); - equal(innerHTML(lis[0]), '0 b', "second item now the 1st item"); - equal(innerHTML(lis[1]), '1 c', "third item now the 2nd item"); + assert.equal(innerHTML(lis[0]), '0 b', "second item now the 1st item"); + assert.equal(innerHTML(lis[1]), '1 c', "third item now the 2nd item"); }); - test("stache.safestring works on live binding (#606)", function () { + QUnit.test("stache.safestring works on live binding (#606)", function(assert) { var num = new SimpleObservable(1); @@ -2934,11 +2934,11 @@ function makeTest(name, doc, mutation) { var template = stache("
                      {{safeHelper()}}
                      ") var frag = template(); - equal(frag.firstChild.firstChild.nodeName.toLowerCase(), "p", "got a p element"); + assert.equal(frag.firstChild.firstChild.nodeName.toLowerCase(), "p", "got a p element"); }); - test("directly nested subitems and each (#605)", function () { + QUnit.test("directly nested subitems and each (#605)", function(assert) { var template = stache("
                      " + @@ -2960,21 +2960,21 @@ function makeTest(name, doc, mutation) { div = frag.firstChild, labels = div.getElementsByTagName("label"); - equal(labels.length, 1, "initially one label"); + assert.equal(labels.length, 1, "initially one label"); data.get('item').get('subitems') .push('second'); labels = div.getElementsByTagName("label"); - equal(labels.length, 2, "after pushing two label"); + assert.equal(labels.length, 2, "after pushing two label"); data.set('item',undefined); labels = div.getElementsByTagName("label"); - equal(labels.length, 0, "after removing item no label"); + assert.equal(labels.length, 0, "after removing item no label"); }); - test("directly nested live sections unbind without needing the element to be removed", function () { + QUnit.test("directly nested live sections unbind without needing the element to be removed", function(assert) { var template = stache( "
                      " + "{{#items}}" + @@ -2993,16 +2993,16 @@ function makeTest(name, doc, mutation) { template(data); - QUnit.ok(meta.handlers.get([]).length, "there is one handler"); + assert.ok(meta.handlers.get([]).length, "there is one handler"); data.set("items", [{ visible: true }]); - QUnit.stop(); + var done = assert.async(); var check = function(){ if(!meta.handlers.get([]).length) { - QUnit.ok(true, "there is no handler"); - QUnit.start(); + assert.ok(true, "there is no handler"); + done(); } else { setTimeout(check,20); } @@ -3013,7 +3013,7 @@ function makeTest(name, doc, mutation) { }); - test("direct live section", function () { + QUnit.test("direct live section", function(assert) { var template = stache("{{#if visible}}
                inside
                {{name}}
                renders correctly (#1013)", 1, function() { + QUnit.test("inside
                renders correctly (#1013)", 1, function(assert) { var template = '
                {{#columns}}{{/columns}}
                '; var frag = stache(template)({ columns: new DefineList([ @@ -3635,10 +3635,10 @@ function makeTest(name, doc, mutation) { var index = getChildNodes(frag).length === 2 ? 1 : 0; var tagName = frag.childNodes.item(index).firstChild.firstChild.tagName.toLowerCase(); - equal(tagName, 'col', ' nodes added in proper position'); + assert.equal(tagName, 'col', ' nodes added in proper position'); }); - test('splicing negative indices works (#1038)', function() { + QUnit.test('splicing negative indices works (#1038)', function(assert) { // http://jsfiddle.net/ZrWVQ/2/ var template = '{{#each list}}

                {{.}}

                {{/each}}'; var list = new DefineList(['a', 'b', 'c', 'd']); @@ -3648,20 +3648,20 @@ function makeTest(name, doc, mutation) { var children = getChildNodes(frag).length; list.splice(-1); - equal(getChildNodes(frag).length, children - 1, 'Child node removed'); + assert.equal(getChildNodes(frag).length, children - 1, 'Child node removed'); }); - test('stache can accept an intermediate (#1387)', function(){ + QUnit.test('stache can accept an intermediate (#1387)', function(assert) { var template = "
                {{message}}
                "; var intermediate = parser(template,{}, true); var renderer = stache(intermediate); var frag = renderer({className: "foo", message: "bar"}); - equal(frag.firstChild.className, "foo", "correct class name"); - equal(innerHTML(frag.firstChild), "bar", "correct innerHTMl"); + assert.equal(frag.firstChild.className, "foo", "correct class name"); + assert.equal(innerHTML(frag.firstChild), "bar", "correct innerHTMl"); }); - test("Passing Partial set in options (#1388 and #1389). Support live binding of partial", function () { + QUnit.test("Passing Partial set in options (#1388 and #1389). Support live binding of partial", function(assert) { var data = new SimpleMap({ name: "World", greeting: "hello" @@ -3674,14 +3674,14 @@ function makeTest(name, doc, mutation) { var div = doc.createElement("div"); div.appendChild(template); - equal(innerHTML(div.firstChild), "hello World", "partial retreived and rendered"); + assert.equal(innerHTML(div.firstChild), "hello World", "partial retreived and rendered"); data.set("greeting", "goodbye"); - equal(innerHTML(div.firstChild), "goodbye World", "Partial updates when attr is updated"); + assert.equal(innerHTML(div.firstChild), "goodbye World", "Partial updates when attr is updated"); }); - test("#each with null or undefined and then a list", function(){ + QUnit.test("#each with null or undefined and then a list", function(assert) { var template = stache("
                  {{#each items}}
                • {{name}}
                • {{/each}}"); var data = new SimpleMap({items: null}); var frag = template(data); @@ -3692,10 +3692,10 @@ function makeTest(name, doc, mutation) { data.set("items", [{name: "foo"}]); - equal(div.getElementsByTagName("li").length, 1, "li added"); + assert.equal(div.getElementsByTagName("li").length, 1, "li added"); }); - test("promises work (#179)", function(){ + QUnit.test("promises work (#179)", function(assert) { var template = stache( "{{#if promise.isPending}}{{/if}}"+ @@ -3717,19 +3717,19 @@ function makeTest(name, doc, mutation) { var spans = rootDiv.getElementsByTagName("span"); - equal(spans.length, 1); - equal(spans[0].getAttribute("class"), "pending"); + assert.equal(spans.length, 1); + assert.equal(spans[0].getAttribute("class"), "pending"); - stop(); + var done = assert.async(); def.resolve({message: "Hi there"}); // better than timeouts would be using can-inserted, but we don't have can/view/bindings setTimeout(function(){ spans = rootDiv.getElementsByTagName("span"); - equal(spans.length, 1); - equal(spans[0].getAttribute("class"), "resolved"); - equal(innerHTML(spans[0]), "Hi there"); + assert.equal(spans.length, 1); + assert.equal(spans[0].getAttribute("class"), "resolved"); + assert.equal(innerHTML(spans[0]), "Hi there"); var def = {}; @@ -3750,17 +3750,17 @@ function makeTest(name, doc, mutation) { setTimeout(function(){ spans = div.getElementsByTagName("span"); - equal(spans.length, 1); - equal(spans[0].getAttribute("class"), "rejected"); - equal(innerHTML(spans[0]), "BORKED"); + assert.equal(spans.length, 1); + assert.equal(spans[0].getAttribute("class"), "rejected"); + assert.equal(innerHTML(spans[0]), "BORKED"); - start(); + done(); }, 30); },30); }); - test("{#list} works right (#1551)", function(){ + QUnit.test("{#list} works right (#1551)", function(assert) { var data = new SimpleMap({}); var template = stache("
                  {{#items}}{{/items}}
                  "); var frag = template(data); @@ -3771,12 +3771,12 @@ function makeTest(name, doc, mutation) { var spans = frag.firstChild.getElementsByTagName("span"); - equal(spans.length,1, "one span"); + assert.equal(spans.length,1, "one span"); }); - test("promises are not rebound (#1572)", function(){ - stop(); + QUnit.test("promises are not rebound (#1572)", function(assert) { + var done = assert.async(); var d = {}; var promise = new Promise(function(resolve, reject){ d.resolve = resolve; @@ -3804,14 +3804,14 @@ function makeTest(name, doc, mutation) { setTimeout(function(){ spans = div.getElementsByTagName("span") - equal(spans.length, 0, "there should be no spans"); - start(); + assert.equal(spans.length, 0, "there should be no spans"); + done(); },30); },10); }); - test("reading alternate values on promises (#1572)", function(){ + QUnit.test("reading alternate values on promises (#1572)", function(assert) { var promise = new Promise(function(resolve, reject){}); promise.myAltProp = "AltValue"; @@ -3819,12 +3819,12 @@ function makeTest(name, doc, mutation) { var frag = template({d: promise}); - equal(innerHTML(frag.firstChild), "AltValue", "read value"); + assert.equal(innerHTML(frag.firstChild), "AltValue", "read value"); }); - test("possible to teardown immediate nodeList (#1593)", function(){ - expect(3); + QUnit.test("possible to teardown immediate nodeList (#1593)", function(assert) { + assert.expect(3); var map = new SimpleMap({show: true}); @@ -3834,18 +3834,18 @@ function makeTest(name, doc, mutation) { var frag = template(map,{},nodeList); nodeLists.update(nodeList, getChildNodes(frag)); - equal(nodeList.length, 1, "our nodeList has the nodeList of #if show"); + assert.equal(nodeList.length, 1, "our nodeList has the nodeList of #if show"); var meta = map[canSymbol.for("can.meta")]; - QUnit.ok(meta.handlers.get([]).length, "there is one handler"); + assert.ok(meta.handlers.get([]).length, "there is one handler"); nodeLists.unregister(nodeList); // has to be async b/c of the temporary bind for performance - QUnit.stop(); + var done = assert.async(); var check = function(){ if(!meta.handlers.get([]).length) { - QUnit.ok(true, "there is no handler"); - QUnit.start(); + assert.ok(true, "there is no handler"); + done(); } else { setTimeout(check,20); } @@ -3856,7 +3856,7 @@ function makeTest(name, doc, mutation) { // the define test doesn't include the stache plugin and // the stache test doesn't include define plugin, so have to put this here - test('#1590 #each with surrounding block and setter', function(){ + QUnit.test('#1590 #each with surrounding block and setter', function(assert) { // the problem here ... is that a batch is happening // the replace is going to happen after // we need to know when to respond @@ -3875,12 +3875,12 @@ function makeTest(name, doc, mutation) { product.set(1); queues.batch.stop(); - equal(frag.firstChild.getElementsByTagName('span').length, 1, "no duplicates"); + assert.equal(frag.firstChild.getElementsByTagName('span').length, 1, "no duplicates"); }); if(doc.createElementNS && System.env !== 'canjs-test') { - test("svg elements for (#1327)", function(){ + QUnit.test("svg elements for (#1327)", function(assert) { var template = stache(''+ ''+ @@ -3889,12 +3889,12 @@ function makeTest(name, doc, mutation) { radius: 6 }); - equal(frag.firstChild.namespaceURI, "http://www.w3.org/2000/svg", "svg namespace"); + assert.equal(frag.firstChild.namespaceURI, "http://www.w3.org/2000/svg", "svg namespace"); }); } - test('using #each when toggling between list and null', function() { + QUnit.test('using #each when toggling between list and null', function(assert) { var state = new SimpleMap(); var div = doc.createElement('div'); var frag = stache('{{#each deepness.rows}}
                  {{/each}}')(state); @@ -3905,10 +3905,10 @@ function makeTest(name, doc, mutation) { }); state.set('deepness', null); - equal(div.getElementsByTagName('div').length, 0, "only the placeholder textnode"); + assert.equal(div.getElementsByTagName('div').length, 0, "only the placeholder textnode"); }); - test("compute defined after template (#1617)", function(){ + QUnit.test("compute defined after template (#1617)", function(assert) { var myMap = new SimpleMap(); // 1. Render a stache template with a binding to a key that is not a canCompute @@ -3917,10 +3917,10 @@ function makeTest(name, doc, mutation) { // 2. Set that key to a canCompute myMap.set('test', new Observation(function() { return "def"; })); - equal(frag.firstChild.firstChild.nodeValue, "def", "correct value"); + assert.equal(frag.firstChild.firstChild.nodeValue, "def", "correct value"); }); - test('template with a block section and nested if doesnt render correctly', function() { + QUnit.test('template with a block section and nested if doesnt render correctly', function(assert) { var myMap = new SimpleMap({ bar: true }); @@ -3929,33 +3929,33 @@ function makeTest(name, doc, mutation) { "{{#bar}}
                  {{#if ../foo}}My Meals{{else}}My Order{{/if}}
                  {{/bar}}" )(myMap); - equal(innerHTML(frag.firstChild), 'My Order', 'shows else case'); + assert.equal(innerHTML(frag.firstChild), 'My Order', 'shows else case'); myMap.set('foo', true); - equal(innerHTML(frag.firstChild), 'My Meals', 'shows if case'); + assert.equal(innerHTML(frag.firstChild), 'My Meals', 'shows if case'); }); - test('addHelper', 3, function() { + QUnit.test('addHelper', 3, function(assert) { var template = stache('
                  Result: {{simple first second}}
                  '); stache.addHelper('simple', function (first, second) { - equal(first, 2); - equal(second, 4); + assert.equal(first, 2); + assert.equal(second, 4); return first + second; }); var frag = template(new SimpleMap({ first: 2, second: 4 })); - equal(innerHTML(frag.firstChild), 'Result: 6'); + assert.equal(innerHTML(frag.firstChild), 'Result: 6'); }); - test('Helper handles list replacement (#1652)', 3, function () { + QUnit.test('Helper handles list replacement (#1652)', 3, function(assert) { var state = new SimpleMap({ list: new DefineList([]) }); var helpers = { listHasLength: function (options) { - ok(true, 'listHasLength helper evaluated'); + assert.ok(true, 'listHasLength helper evaluated'); return this.get('list').get('length') ? options.fn() : options.inverse(); @@ -3972,7 +3972,7 @@ function makeTest(name, doc, mutation) { state.get('list').push('...') }); - test('Helper binds to nested properties (#1651)', function () { + QUnit.test('Helper binds to nested properties (#1651)', function(assert) { var nestedAttrsCount = 0, state = new SimpleMap({ @@ -3985,7 +3985,7 @@ function makeTest(name, doc, mutation) { nestedAttrsCount++; if (nestedAttrsCount === 3) { - ok(true, 'bindViaNestedAttrs helper evaluated 3 times'); + assert.ok(true, 'bindViaNestedAttrs helper evaluated 3 times'); } return this.get('parent') && this.get('parent').get('child') ? @@ -4008,7 +4008,7 @@ function makeTest(name, doc, mutation) { - test("Handlebars helper: switch/case", function() { + QUnit.test("Handlebars helper: switch/case", function(assert) { var expected; var t = { template: '{{#switch ducks}}{{#case "10"}}10 ducks{{/case}}' + @@ -4029,16 +4029,16 @@ function makeTest(name, doc, mutation) { }; expected = t.expected.replace(/"/g, '"').replace(/\r\n/g, '\n'); - deepEqual(getText(t.template, t.data), expected); + assert.deepEqual(getText(t.template, t.data), expected); - deepEqual(getText(t.template, t.liveData), expected); + assert.deepEqual(getText(t.template, t.liveData), expected); t.data.ducks = 5; - deepEqual(getText(t.template, t.data), 'Not 10 ducks'); + assert.deepEqual(getText(t.template, t.data), 'Not 10 ducks'); }); - test("Handlebars helper: switch - changing to default (#1857)", function(){ + QUnit.test("Handlebars helper: switch - changing to default (#1857)", function(assert) { var template = stache('{{#switch ducks}}{{#case "10"}}10 ducks{{/case}}' + '{{#default}}Not 10 ducks{{/default}}{{/switch}}'); var map = new SimpleMap({ @@ -4047,14 +4047,14 @@ function makeTest(name, doc, mutation) { var frag = template(map); - deepEqual(getTextFromFrag(frag), "10 ducks"); + assert.deepEqual(getTextFromFrag(frag), "10 ducks"); map.set("ducks", "12"); - deepEqual(getTextFromFrag(frag), "Not 10 ducks"); + assert.deepEqual(getTextFromFrag(frag), "Not 10 ducks"); }); - test("joinBase helper joins to the baseURL", function(){ + QUnit.test("joinBase helper joins to the baseURL", function(assert) { var baseUrl = System.baseURL || getBaseURL(); var template = stache("{{joinBase 'hello/' name}}"); @@ -4062,11 +4062,11 @@ function makeTest(name, doc, mutation) { var frag = template(map); - equal(frag.firstChild.nodeValue, joinURIs(baseUrl, "hello/world"), "joined from baseUrl"); + assert.equal(frag.firstChild.nodeValue, joinURIs(baseUrl, "hello/world"), "joined from baseUrl"); }); - test("joinBase helper can be relative to template module", function(){ + QUnit.test("joinBase helper can be relative to template module", function(assert) { var baseUrl = "http://foocdn.com/bitovi"; var template = stache("{{joinBase '../hello/' name}}"); @@ -4074,14 +4074,14 @@ function makeTest(name, doc, mutation) { var frag = template(map, { module: { uri: baseUrl } }); - equal(frag.firstChild.nodeValue, "http://foocdn.com/hello/world", "relative lookup works"); + assert.equal(frag.firstChild.nodeValue, "http://foocdn.com/hello/world", "relative lookup works"); }); - test('Custom attribute callbacks are called when in a conditional within a live section', 6, function () { + QUnit.test('Custom attribute callbacks are called when in a conditional within a live section', 6, function(assert) { viewCallbacks.attr('test-attr', function(el, attrData) { - ok(true, "test-attr called"); - equal(attrData.attributeName, 'test-attr', "attributeName set correctly"); - ok(attrData.scope, "scope isn't undefined"); + assert.ok(true, "test-attr called"); + assert.equal(attrData.attributeName, 'test-attr', "attributeName set correctly"); + assert.ok(attrData.scope, "scope isn't undefined"); }); var state = new SimpleMap({ @@ -4095,7 +4095,7 @@ function makeTest(name, doc, mutation) { state.set('showAttr', true); }); - test("inner expressions (#1769)", function(){ + QUnit.test("inner expressions (#1769)", function(assert) { var template = stache("{{helperA helperB(1,valueA,propA=valueB propC=2) 'def' outerPropA=helperC(2, ~valueB)}}"); @@ -4104,29 +4104,29 @@ function makeTest(name, doc, mutation) { valueB: "B" }),{ helperA: function(arg1, arg2, options){ - equal(arg1(), "helperB value", "call expression argument to helperA"); - equal(arg2, "def", "scope argument"); - equal(options.hash.outerPropA(), "helperC value", "scope hash"); + assert.equal(arg1(), "helperB value", "call expression argument to helperA"); + assert.equal(arg2, "def", "scope argument"); + assert.equal(options.hash.outerPropA(), "helperC value", "scope hash"); return "helperA value"; }, helperB: function(arg1, arg2, options){ - equal(arg1, 1, "static argument"); - equal(arg2, "A", "scope argument"); - equal(options.propA, "B", "scope hash"); - equal(options.propC, 2, "static hash"); + assert.equal(arg1, 1, "static argument"); + assert.equal(arg2, "A", "scope argument"); + assert.equal(options.propA, "B", "scope hash"); + assert.equal(options.propC, 2, "static hash"); return "helperB value"; }, helperC: function(arg1, arg2){ - equal(arg1, 2, "helperC static argument"); - equal(arg2(), "B", "helperC scope argument"); + assert.equal(arg1, 2, "helperC static argument"); + assert.equal(arg2(), "B", "helperC scope argument"); return "helperC value"; } }); - equal(frag.firstChild.nodeValue, "helperA value"); + assert.equal(frag.firstChild.nodeValue, "helperA value"); }); - test("inner expressions with computes", function(){ + QUnit.test("inner expressions with computes", function(assert) { var template = stache("{{helperA helperB(1,valueA,propA=valueB propC=2) 'def' outerPropA=helperC(2,valueB)}}"); @@ -4140,55 +4140,55 @@ function makeTest(name, doc, mutation) { helperA: function(arg1, arg2, options){ if(changes === 0) { - equal(arg1(), "helperB=B", "static argument"); - equal(options.hash.outerPropA(), "helperC=B", "scope hash 0"); + assert.equal(arg1(), "helperB=B", "static argument"); + assert.equal(options.hash.outerPropA(), "helperC=B", "scope hash 0"); } else { - equal(arg1(), "helperB=X", "static argument"); - equal(options.hash.outerPropA(), "helperC=X", "scope hash 1"); + assert.equal(arg1(), "helperB=X", "static argument"); + assert.equal(options.hash.outerPropA(), "helperC=X", "scope hash 1"); } - equal(arg2, "def", "scope argument"); + assert.equal(arg2, "def", "scope argument"); return arg1()+"-"+options.hash.outerPropA(); }, helperB: function(arg1, arg2, options){ - equal(arg1, 1, "static argument"); - equal(arg2, "A", "scope argument"); + assert.equal(arg1, 1, "static argument"); + assert.equal(arg2, "A", "scope argument"); if(changes === 0) { - equal(options.propA, "B", "scope hash"); + assert.equal(options.propA, "B", "scope hash"); } else { - equal(options.propA, "X", "scope hash"); + assert.equal(options.propA, "X", "scope hash"); } - equal(options.propC, 2, "static hash"); + assert.equal(options.propC, 2, "static hash"); return "helperB="+options.propA; }, helperC: function(arg1, arg2){ - equal(arg1, 2, "helperC static argument"); + assert.equal(arg1, 2, "helperC static argument"); if(changes === 0) { - equal(arg2, "B", "helperC scope argument"); + assert.equal(arg2, "B", "helperC scope argument"); } else { - equal(arg2, "X", "helperC scope argument"); + assert.equal(arg2, "X", "helperC scope argument"); } return "helperC="+arg2; } }); - equal(frag.firstChild.nodeValue, "helperB=B-helperC=B"); + assert.equal(frag.firstChild.nodeValue, "helperB=B-helperC=B"); changes++; queues.batch.start(); valueB.set("X"); queues.batch.stop(); - equal(frag.firstChild.nodeValue, "helperB=X-helperC=X"); + assert.equal(frag.firstChild.nodeValue, "helperB=X-helperC=X"); }); - test("parent scope functions not called with arguments (#1833)", function(){ + QUnit.test("parent scope functions not called with arguments (#1833)", function(assert) { var data = { child: {value: 1}, method: function(arg){ - equal(arg, 1, "got the right arg"); + assert.equal(arg, 1, "got the right arg"); } }; @@ -4196,7 +4196,7 @@ function makeTest(name, doc, mutation) { template(data); }); - test("call expression - simple", function(){ + QUnit.test("call expression - simple", function(assert) { var template = stache("{{method(arg)}}"); var age = new SimpleObservable(32); @@ -4207,11 +4207,11 @@ function makeTest(name, doc, mutation) { arg: age }); - equal( frag.firstChild.nodeValue, "64", "method call works"); + assert.equal( frag.firstChild.nodeValue, "64", "method call works"); }); - test("call expression #each passed list", function () { + QUnit.test("call expression #each passed list", function(assert) { var animals = new DefineList(['sloth', 'bear']), renderer = stache("
                  myfavoriteanimals:{{#eachOf(animals)}} {{this}}{{/}}!
                  "); @@ -4226,18 +4226,18 @@ function makeTest(name, doc, mutation) { div.getElementsByTagName('label')[0].myexpando = "EXPANDO-ED"; //animals.push("dog") - equal(div.getElementsByTagName('label') + assert.equal(div.getElementsByTagName('label') .length, 2, "There are 2 labels"); animals.push("turtle"); - equal(div.getElementsByTagName('label')[0].myexpando, "EXPANDO-ED", "same expando"); + assert.equal(div.getElementsByTagName('label')[0].myexpando, "EXPANDO-ED", "same expando"); - equal(innerHTML(div.getElementsByTagName('span')[2]), "turtle", "turtle added"); + assert.equal(innerHTML(div.getElementsByTagName('span')[2]), "turtle", "turtle added"); }); - test("call expression #each passed compute", function () { + QUnit.test("call expression #each passed compute", function(assert) { var animals = new SimpleObservable( new DefineList(['sloth', 'bear']) ), renderer = stache("
                  myfavoriteanimals:{{#eachOf(~animals)}} {{this}}{{/}}!
                  "); @@ -4252,23 +4252,23 @@ function makeTest(name, doc, mutation) { div.getElementsByTagName('label')[0].myexpando = "EXPANDO-ED"; //animals.push("dog") - equal(div.getElementsByTagName('label') + assert.equal(div.getElementsByTagName('label') .length, 2, "There are 2 labels"); animals.set( new DefineList(['sloth', 'bear','turtle']) ); - equal(div.getElementsByTagName('label')[0].myexpando, "EXPANDO-ED", "same expando"); + assert.equal(div.getElementsByTagName('label')[0].myexpando, "EXPANDO-ED", "same expando"); - equal(innerHTML(div.getElementsByTagName('span')[2]), "turtle", "turtle added"); + assert.equal(innerHTML(div.getElementsByTagName('span')[2]), "turtle", "turtle added"); }); - test('getHelper w/o optional options argument (#1497)', function() { + QUnit.test('getHelper w/o optional options argument (#1497)', function(assert) { var helper = stache.getHelper('each'); - ok(typeof helper === 'function', 'each helper returned'); + assert.ok(typeof helper === 'function', 'each helper returned'); }); - test("methods don't update correctly (#1891)", function() { + QUnit.test("methods don't update correctly (#1891)", function(assert) { var map = new SimpleMap({ num1: 1, num2: function () { return this.get('num1') * 2; } @@ -4277,20 +4277,20 @@ function makeTest(name, doc, mutation) { '{{num1}}' + '{{num2()}}')(map); - equal(frag.firstChild.firstChild.nodeValue, '1', 'Rendered correct value'); - equal(frag.lastChild.firstChild.nodeValue, '2', 'Rendered correct value'); + assert.equal(frag.firstChild.firstChild.nodeValue, '1', 'Rendered correct value'); + assert.equal(frag.lastChild.firstChild.nodeValue, '2', 'Rendered correct value'); map.set('num1', map.get('num1') * 2); - equal(frag.firstChild.firstChild.nodeValue, '2', 'Rendered correct value'); - equal(frag.lastChild.firstChild.nodeValue, '4', 'Rendered correct value'); + assert.equal(frag.firstChild.firstChild.nodeValue, '2', 'Rendered correct value'); + assert.equal(frag.lastChild.firstChild.nodeValue, '4', 'Rendered correct value'); }); - test('eq called twice (#1931)', function() { - expect(1); + QUnit.test('eq called twice (#1931)', function(assert) { + assert.expect(1); var origEq = overwriteGlobalHelper('eq', function() { - ok(true, 'comparator invoked only once during setup'); + assert.ok(true, 'comparator invoked only once during setup'); return origEq.apply(this, arguments); }); @@ -4306,18 +4306,18 @@ function makeTest(name, doc, mutation) { overwriteGlobalHelper('eq', origEq); }); - test("#each with else works (#1979)", function(){ + QUnit.test("#each with else works (#1979)", function(assert) { var list = new DefineList(["a","b"]); var template = stache("
                  {{#each list}}{{.}}{{else}}{{/each}}
                  "); var frag = template({list: list}); list.replace([]); var spans = frag.firstChild.getElementsByTagName("span"); var labels = frag.firstChild.getElementsByTagName("label"); - equal(spans.length, 0, "truthy case doesn't render"); - equal(labels.length, 1, "empty case"); + assert.equal(spans.length, 0, "truthy case doesn't render"); + assert.equal(labels.length, 1, "empty case"); }); - test("Re-evaluating a case in a switch (#1988)", function(){ + QUnit.test("Re-evaluating a case in a switch (#1988)", function(assert) { var template = stache( "{{#switch page}}" + "{{#case 'home'}}" + @@ -4343,25 +4343,25 @@ function makeTest(name, doc, mutation) { var frag = template(map); - equal(frag.firstChild.getAttribute("id"), "home", "'home' is the first item shown"); + assert.equal(frag.firstChild.getAttribute("id"), "home", "'home' is the first item shown"); map.set("page", "users"); - equal(frag.firstChild.nextSibling.getAttribute("id"), "users", "'users' is the item shown when the page is users"); + assert.equal(frag.firstChild.nextSibling.getAttribute("id"), "users", "'users' is the item shown when the page is users"); map.set("slug", "Matthew"); - equal(frag.firstChild.nextSibling.getAttribute("id"), "user", "'user' is the item shown when the page is users and there is a slug"); + assert.equal(frag.firstChild.nextSibling.getAttribute("id"), "user", "'user' is the item shown when the page is users and there is a slug"); queues.batch.start(); map.set("page", "home"); map.set("slug", undefined); queues.batch.stop(); - equal(frag.firstChild.getAttribute("id"), "home", "'home' is the first item shown"); - equal(frag.firstChild.nextSibling.nodeType, 3, "the next sibling is a TextNode"); - equal(frag.firstChild.nextSibling.nextSibling, undefined, "there are no more nodes"); + assert.equal(frag.firstChild.getAttribute("id"), "home", "'home' is the first item shown"); + assert.equal(frag.firstChild.nextSibling.nodeType, 3, "the next sibling is a TextNode"); + assert.equal(frag.firstChild.nextSibling.nextSibling, undefined, "there are no more nodes"); }); - test("Rendering live bound indices with #each, scope.index and a simple CanList (#2067)", function () { + QUnit.test("Rendering live bound indices with #each, scope.index and a simple CanList (#2067)", function(assert) { var list = new DefineList([{value:'a'}, {value:'b'}, {value: 'c'}]); var template = stache("
                    {{#each list}}
                  • {{scope.index}} {{value}}
                  • {{/each}}
                  "); @@ -4371,57 +4371,57 @@ function makeTest(name, doc, mutation) { //.getElementsByTagName('li'); var lis = tpl.getElementsByTagName('li'); - equal(lis.length, 3, "three lis"); + assert.equal(lis.length, 3, "three lis"); - equal(innerHTML(lis[0]), '0 a', "first index and value are correct"); - equal(innerHTML(lis[1]), '1 b', "second index and value are correct"); - equal(innerHTML(lis[2]), '2 c', "third index and value are correct"); + assert.equal(innerHTML(lis[0]), '0 a', "first index and value are correct"); + assert.equal(innerHTML(lis[1]), '1 b', "second index and value are correct"); + assert.equal(innerHTML(lis[2]), '2 c', "third index and value are correct"); }); - test("scope.index content should be skipped by ../ (#1554)", function(){ + QUnit.test("scope.index content should be skipped by ../ (#1554)", function(assert) { var list = new DefineList(["a","b"]); var tmpl = stache('{{#each items}}
                • {{.././items.indexOf(this)}}
                • {{/each}}'); var frag = tmpl({items: list}); - equal(frag.lastChild.firstChild.nodeValue, "1", "read indexOf"); + assert.equal(frag.lastChild.firstChild.nodeValue, "1", "read indexOf"); }); - test("rendering style tag (#2035)",function(){ + QUnit.test("rendering style tag (#2035)",function(assert) { var map = new SimpleMap({color: 'green'}); var frag = stache('')(map); var content = frag.firstChild.firstChild.nodeValue; - equal(content,"body {color: green }","got the right style text"); + assert.equal(content,"body {color: green }","got the right style text"); map = new SimpleMap({showGreen: true}); frag = stache('')(map); content = frag.firstChild.firstChild.nodeValue; - equal(content,"body {color: green }","sub expressions work"); + assert.equal(content,"body {color: green }","sub expressions work"); }); - test("checked as a custom attribute", function(){ + QUnit.test("checked as a custom attribute", function(assert) { var map = new SimpleMap({ preview: true }); var frag = stache("
                  ")(map); - equal(frag.firstChild.getAttribute("checked"), "", "got attribute"); + assert.equal(frag.firstChild.getAttribute("checked"), "", "got attribute"); }); - test("sections with attribute spacing (#2097)", function(){ + QUnit.test("sections with attribute spacing (#2097)", function(assert) { var template = stache('
                  '); var frag = template({foo: true}); - equal(frag.firstChild.getAttribute("disabled"),"","disabled set"); + assert.equal(frag.firstChild.getAttribute("disabled"),"","disabled set"); }); - test("readonly as a custom attribute", function() { + QUnit.test("readonly as a custom attribute", function(assert) { var map = new DefineMap({ conditions: false }); var frag = stache('')(map); - equal(frag.firstChild.getAttribute("readonly"),"","readonly set"); + assert.equal(frag.firstChild.getAttribute("readonly"),"","readonly set"); }); - test("keep scope.index working with multi-dimensional arrays (#2127)", function() { + QUnit.test("keep scope.index working with multi-dimensional arrays (#2127)", function(assert) { var data = new SimpleMap({ array2 : [['asd'], ['sdf']] }); @@ -4431,10 +4431,10 @@ function makeTest(name, doc, mutation) { var frag = template(data); var spans = frag.firstChild.getElementsByTagName("span"); - equal( spans[0].firstChild.nodeValue, "0"); + assert.equal( spans[0].firstChild.nodeValue, "0"); }); - test("nested switch statement fail (#2188)", function(){ + QUnit.test("nested switch statement fail (#2188)", function(assert) { var template = stache("
                  {{#switch outer}}"+ '{{#case "outerValue1"}}'+ @@ -4463,13 +4463,13 @@ function makeTest(name, doc, mutation) { queues.batch.stop(); - ok( innerHTML(frag.firstChild).indexOf("OUTER2") >= 0, "has OUTER2"); - ok( innerHTML(frag.firstChild).indexOf("INNER1") === -1, "does not have INNER1"); + assert.ok( innerHTML(frag.firstChild).indexOf("OUTER2") >= 0, "has OUTER2"); + assert.ok( innerHTML(frag.firstChild).indexOf("INNER1") === -1, "does not have INNER1"); }); - test('Child bindings are called before the parent', function() { + QUnit.test('Child bindings are called before the parent', function(assert) { var template = "{{#eq page 'todos'}}" + "{{#eq action 'view'}} {{trace 'view todos'}} {{/eq}}" + "{{#eq action 'edit'}} {{trace 'edit todos'}} {{/eq}}" + @@ -4489,11 +4489,11 @@ function makeTest(name, doc, mutation) { trace: function(value, options) { if(counter === 0) { - equal(value, 'view todos'); + assert.equal(value, 'view todos'); } else if(counter === 1) { - equal(value, 'edit recipes') + assert.equal(value, 'edit recipes') } else { - ok(false, 'Traced an unexpected template call: '+value); + assert.ok(false, 'Traced an unexpected template call: '+value); } counter++; } @@ -4505,10 +4505,10 @@ function makeTest(name, doc, mutation) { }); queues.batch.stop(); - equal(counter, 2, 'Counter incremented twice'); + assert.equal(counter, 2, 'Counter incremented twice'); }); - test("scope.index is double wrapped compute in helper (#2179)", function(){ + QUnit.test("scope.index is double wrapped compute in helper (#2179)", function(assert) { var appState = new SimpleMap({ todos: [ { description: "Foo" }, @@ -4520,14 +4520,14 @@ function makeTest(name, doc, mutation) { stache.registerHelper("indexPlusOne", function(val, options) { var resolved = val(); - equal(typeof resolved,"number", "should be a number"); + assert.equal(typeof resolved,"number", "should be a number"); return resolved + 2; }); template(appState); }); - test("scope.index is double wrapped compute in helper (#2179)", function(){ + QUnit.test("scope.index is double wrapped compute in helper (#2179)", function(assert) { var appState = new SimpleMap({ todos: [ { description: "Foo" }, @@ -4539,14 +4539,14 @@ function makeTest(name, doc, mutation) { stache.registerHelper("indexPlusOne", function(val, options) { var resolved = val(); - equal(typeof resolved,"number", "should be a number"); + assert.equal(typeof resolved,"number", "should be a number"); return resolved + 2; }); template(appState); }); - test("nested sections work (#2229)", function(){ + QUnit.test("nested sections work (#2229)", function(assert) { var template = stache('
                  '); var vm = new SimpleMap({ @@ -4719,7 +4719,7 @@ function makeTest(name, doc, mutation) { assert.equal( className, 'sort-ascend'); }); - test('Helper each inside a text section (attribute) (#8)', function(assert){ + QUnit.test('Helper each inside a text section (attribute) (#8)', function(assert){ var template = stache('
                  '); var vm = new SimpleMap({ @@ -4736,7 +4736,7 @@ function makeTest(name, doc, mutation) { assert.equal( className, 'one two three ' ); }); - test("stache.from works (#57)", function(assert){ + QUnit.test("stache.from works (#57)", function(assert){ var script = DOCUMENT().createElement("script"); script.type = "type/stache"; script.innerHTML = "{{message}}"; @@ -4749,7 +4749,7 @@ function makeTest(name, doc, mutation) { assert.equal(frag.firstChild.nodeValue, "Hello"); }); - test("foo().bar", function () { + QUnit.test("foo().bar", function(assert) { var template = stache("

                  {{ person().name }}

                  "); var div = doc.createElement('div'); @@ -4765,14 +4765,14 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'Kevin', 'correct value for person().name'); + assert.equal(innerHTML(p[0]), 'Kevin', 'correct value for person().name'); data.set('name', 'Kevin Phillips'); - equal(innerHTML(p[0]), 'Kevin Phillips', 'updated value for person().name'); + assert.equal(innerHTML(p[0]), 'Kevin Phillips', 'updated value for person().name'); }); - test("foo().bar - DefineMap", function () { + QUnit.test("foo().bar - DefineMap", function(assert) { var template = stache("

                  {{ person().name }}

                  "); var div = doc.createElement('div'); @@ -4788,14 +4788,14 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'Kevin', 'correct value for person().name'); + assert.equal(innerHTML(p[0]), 'Kevin', 'correct value for person().name'); data.name = 'Kevin Phillips'; - equal(innerHTML(p[0]), 'Kevin Phillips', 'updated value for person().name'); + assert.equal(innerHTML(p[0]), 'Kevin Phillips', 'updated value for person().name'); }); - test("each values update when replaced in a SimpleMap (#62)", function () { + QUnit.test("each values update when replaced in a SimpleMap (#62)", function(assert) { var template = stache("{{#each this}}

                  {{.}}

                  {{/each}}"); var div = doc.createElement('div'); var vm = new SimpleMap({ @@ -4806,10 +4806,10 @@ function makeTest(name, doc, mutation) { vm.set('foo', 'bar-value'); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'bar-value', 'updated the value inside #each'); + assert.equal(innerHTML(p[0]), 'bar-value', 'updated the value inside #each'); }); - test("Bracket expression as argument to Call expression", function () { + QUnit.test("Bracket expression as argument to Call expression", function(assert) { var template = stache("{{ foo([bar]) }}"); var div = doc.createElement('div'); var vm = new SimpleMap({ @@ -4822,10 +4822,10 @@ function makeTest(name, doc, mutation) { var dom = template(vm); div.appendChild(dom); - equal(innerHTML(div), 'Kevin!', 'works'); + assert.equal(innerHTML(div), 'Kevin!', 'works'); }); - test("Bracket expression with undefined value", function() { + QUnit.test("Bracket expression with undefined value", function(assert) { var template = stache("{{ place['place:name'] }}"); var div = doc.createElement('div'); var vm = new SimpleMap({ @@ -4834,14 +4834,14 @@ function makeTest(name, doc, mutation) { var dom = template(vm); div.appendChild(dom); - equal(innerHTML(div), '', 'empty'); + assert.equal(innerHTML(div), '', 'empty'); vm.set('place', { 'place:name': 'bar' }); - equal(innerHTML(div), 'bar', 'updated'); + assert.equal(innerHTML(div), 'bar', 'updated'); }); - test("Bracket expression in multi-argument helpers (Literals)", function() { + QUnit.test("Bracket expression in multi-argument helpers (Literals)", function(assert) { var template = stache("{{#eq place['place:name'] 'foo' }}yes{{else}}no{{/eq}}"); var div = doc.createElement('div'); var vm = new SimpleMap({ @@ -4852,14 +4852,14 @@ function makeTest(name, doc, mutation) { var dom = template(vm); div.appendChild(dom); - equal(innerHTML(div), 'yes', 'initially true'); + assert.equal(innerHTML(div), 'yes', 'initially true'); vm.get('place').set('place:name', 'bar' ); - equal(innerHTML(div), 'no', 'updated'); + assert.equal(innerHTML(div), 'no', 'updated'); }); - test("Bracket expression in multi-argument helpers (Lookups)", function() { + QUnit.test("Bracket expression in multi-argument helpers (Lookups)", function(assert) { var template = stache("{{#eq place[foo] foo }}yes{{else}}no{{/eq}}"); var div = doc.createElement('div'); var vm = new SimpleMap({ @@ -4871,14 +4871,14 @@ function makeTest(name, doc, mutation) { var dom = template(vm); div.appendChild(dom); - equal(innerHTML(div), 'yes', 'initially true'); + assert.equal(innerHTML(div), 'yes', 'initially true'); vm.get('place').set('foo', 'bar' ); - equal(innerHTML(div), 'no', 'updated'); + assert.equal(innerHTML(div), 'no', 'updated'); }); - test("Bracket expression followed by bracket expression", function () { + QUnit.test("Bracket expression followed by bracket expression", function(assert) { var template; var div = doc.createElement('div'); @@ -4902,18 +4902,18 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'K', 'correct value for foo[bar][baz]'); + assert.equal(innerHTML(p[0]), 'K', 'correct value for foo[bar][baz]'); data.set('bar', 'fullName'); - equal(innerHTML(p[0]), 'Kevin', 'updated value for bar in foo[bar][baz]'); + assert.equal(innerHTML(p[0]), 'Kevin', 'updated value for bar in foo[bar][baz]'); data.set('baz', 'last'); - equal(innerHTML(p[0]), 'Phillips', 'updated value for baz in foo[bar][baz]'); + assert.equal(innerHTML(p[0]), 'Phillips', 'updated value for baz in foo[bar][baz]'); }); - test("Bracket expression with numeric index", function () { + QUnit.test("Bracket expression with numeric index", function(assert) { var template, dom, p; var div = doc.createElement('div'); @@ -4933,7 +4933,7 @@ function makeTest(name, doc, mutation) { dom = template(data); div.appendChild(dom); p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'baz', 'correct value for foo[0]'); + assert.equal(innerHTML(p[0]), 'baz', 'correct value for foo[0]'); div.innerHTML = ''; @@ -4942,7 +4942,7 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'thudjeek', 'correct value for bar[scope.index] when iterating foo (Map/List data)'); + assert.equal(innerHTML(p[0]), 'thudjeek', 'correct value for bar[scope.index] when iterating foo (Map/List data)'); div.innerHTML = ''; @@ -4950,10 +4950,10 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'thudjeek', 'correct value for bar[scope.index] when iterating foo (plain object data)'); + assert.equal(innerHTML(p[0]), 'thudjeek', 'correct value for bar[scope.index] when iterating foo (plain object data)'); }); - test("Bracket expression followed by Lookup expression", function () { + QUnit.test("Bracket expression followed by Lookup expression", function(assert) { var template; var div = doc.createElement('div'); @@ -4975,16 +4975,16 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'K', 'correct value for foo[bar].first'); - equal(innerHTML(p[1]), 'short', 'correct value for `is foo[bar].first "K"`'); + assert.equal(innerHTML(p[0]), 'K', 'correct value for foo[bar].first'); + assert.equal(innerHTML(p[1]), 'short', 'correct value for `is foo[bar].first "K"`'); data.set('bar', 'fullName'); - equal(innerHTML(p[0]), 'Kevin', 'updated value for foo[bar].first'); - equal(innerHTML(p[1]), 'long', 'updated value for `is foo[bar].first "K"`'); + assert.equal(innerHTML(p[0]), 'Kevin', 'updated value for foo[bar].first'); + assert.equal(innerHTML(p[1]), 'long', 'updated value for `is foo[bar].first "K"`'); }); - test("renderer itself is not observable", function() { + QUnit.test("renderer itself is not observable", function(assert) { var first = new SimpleObservable("Justin"), last = new SimpleObservable("Meyer"); @@ -4995,54 +4995,54 @@ function makeTest(name, doc, mutation) { }); canReflect.onValue( fullNameFrag, function(){ - QUnit.ok(false); + assert.ok(false); }); this.fixture.appendChild(fullNameFrag.get()); first.set("Josh"); - equal(this.fixture.innerHTML, "Josh Meyer"); + assert.equal(this.fixture.innerHTML, "Josh Meyer"); }); - QUnit.test("content is registered (#163)",function(){ - QUnit.ok( viewCallbacks.tag("content"),"registered content" ); + QUnit.test("content is registered (#163)",function(assert) { + assert.ok( viewCallbacks.tag("content"),"registered content" ); }); - test("whitespace control (#60)", function() { - equal(core.cleanWhitespaceControl( + QUnit.test("whitespace control (#60)", function(assert) { + assert.equal(core.cleanWhitespaceControl( " {{-message-}} "), "{{message}}"); - equal(core.cleanWhitespaceControl( + assert.equal(core.cleanWhitespaceControl( " {{{-message-}}} "), "{{{message}}}"); - equal(core.cleanWhitespaceControl( + assert.equal(core.cleanWhitespaceControl( " {{- name -}} {{{- name -}}} "), "{{ name }}{{{ name }}}"); - equal(core.cleanWhitespaceControl( + assert.equal(core.cleanWhitespaceControl( " {{-#data-}} {{->list-}} {{-/data-}} "), "{{#data}}{{>list}}{{/data}}"); - equal(core.cleanWhitespaceControl( + assert.equal(core.cleanWhitespaceControl( "\n\t{{-! comment -}}\n"), "{{! comment }}"); // right only - equal(core.cleanWhitespaceControl( + assert.equal(core.cleanWhitespaceControl( "\n\t{{! comment -}}\n"), "\n\t{{! comment }}"); // left only - equal(core.cleanWhitespaceControl( + assert.equal(core.cleanWhitespaceControl( "\n\t{{-! comment }}\n"), "{{! comment }}\n"); // both without output - equal(core.cleanWhitespaceControl( + assert.equal(core.cleanWhitespaceControl( "\n\t{{--}}\n"), ""); var div = doc.createElement('div'); div.appendChild(stache("\n\t{{-! comment -}}\n")()); - equal(div.innerHTML, ''); + assert.equal(div.innerHTML, ''); if (typeof div.querySelectorAll === 'function') { - equal(div.querySelectorAll(':empty').length, 1); + assert.equal(div.querySelectorAll(':empty').length, 1); } }); @@ -5052,7 +5052,7 @@ function makeTest(name, doc, mutation) { "unknown attribute binding ($weirdattribute). Is can-stache-bindings imported?", function(message, matched) { if(matched) { - QUnit.ok(true, "warning logged"); + assert.ok(true, "warning logged"); teardown(); done(); } @@ -5070,28 +5070,28 @@ function makeTest(name, doc, mutation) { }); }); - test("@arg functions are not called (#172)", function() { + QUnit.test("@arg functions are not called (#172)", function(assert) { var data = new DefineMap({ func1: function() { return "called"; }, func2: function() { - ok(false, "this method should not be called."); + assert.ok(false, "this method should not be called."); return true; }, noop: undefined }); - equal(getText("{{func1()}}", data), "called"); - equal(getText("{{#if func1()}}yes{{else}}no{{/if}}", data), "yes"); - equal(getText("{{#if func2}}yes{{else}}no{{/if}}", data), "yes"); + assert.equal(getText("{{func1()}}", data), "called"); + assert.equal(getText("{{#if func1()}}yes{{else}}no{{/if}}", data), "yes"); + assert.equal(getText("{{#if func2}}yes{{else}}no{{/if}}", data), "yes"); - equal(getText("{{noop}}", data), ""); - equal(getText("{{#if noop}}yes{{else}}no{{/if}}", data), "no"); + assert.equal(getText("{{noop}}", data), ""); + assert.equal(getText("{{#if noop}}yes{{else}}no{{/if}}", data), "no"); }); - test("can-template works", function() { + QUnit.test("can-template works", function(assert) { var frag; var template = stache( @@ -5102,16 +5102,16 @@ function makeTest(name, doc, mutation) { ''); viewCallbacks.tag("my-email", function(el, tagData){ - ok(tagData.templates, "has templates"); + assert.ok(tagData.templates, "has templates"); frag = tagData.templates.subject({subject: "Hello"}) - QUnit.equal(frag.firstChild.nodeName, 'H2'); - QUnit.equal(frag.firstChild.firstChild.nodeValue, "Hello"); + assert.equal(frag.firstChild.nodeName, 'H2'); + assert.equal(frag.firstChild.firstChild.nodeValue, "Hello"); }); frag = template({}); }); - test("can-template works with multiple can-templates of the same name", function() { + QUnit.test("can-template works with multiple can-templates of the same name", function(assert) { var count = 2, frag; @@ -5128,16 +5128,16 @@ function makeTest(name, doc, mutation) { ''); viewCallbacks.tag("my-email", function(el, tagData){ - ok(tagData.templates, "has templates"); + assert.ok(tagData.templates, "has templates"); frag = tagData.templates.subject({subject: "Hello"}) - QUnit.equal(frag.firstChild.nodeName, 'H' + count++); - QUnit.equal(frag.firstChild.firstChild.nodeValue, "Hello"); + assert.equal(frag.firstChild.nodeName, 'H' + count++); + assert.equal(frag.firstChild.firstChild.nodeValue, "Hello"); }); frag = template({}); }); - test("can-template works with no content (#418)", function() { + QUnit.test("can-template works with no content (#418)", function(assert) { var frag; var template = stache( @@ -5147,14 +5147,14 @@ function makeTest(name, doc, mutation) { ''); viewCallbacks.tag("my-email", function(el, tagData){ - QUnit.ok(tagData.templates, "has templates"); - QUnit.notOk(tagData.templates.subject, 'no subject template'); + assert.ok(tagData.templates, "has templates"); + assert.notOk(tagData.templates.subject, 'no subject template'); }); frag = template({}); }); - test("#each with arrays (#215)", function(){ + QUnit.test("#each with arrays (#215)", function(assert) { var which = new SimpleObservable(false); var a = {}, b = {}, c = {}; @@ -5176,20 +5176,20 @@ function makeTest(name, doc, mutation) { var aLI2 = lis[0], cLI2 = lis[2]; - QUnit.equal(aLI, aLI2, "a li was reused"); - QUnit.equal(cLI, cLI2, "c li was reused"); + assert.equal(aLI, aLI2, "a li was reused"); + assert.equal(cLI, cLI2, "c li was reused"); }); - test("Plain JS object scope works with subtemplate (#208)", function(){ + QUnit.test("Plain JS object scope works with subtemplate (#208)", function(assert) { - expect(3); + assert.expect(3); viewCallbacks.tag("stache-tag", function(el, tagData){ - ok(tagData.scope instanceof Scope, "got scope"); - equal(typeof tagData.subtemplate, "function", "got subtemplate"); + assert.ok(tagData.scope instanceof Scope, "got scope"); + assert.equal(typeof tagData.subtemplate, "function", "got subtemplate"); var frag = tagData.subtemplate({last: "Meyer"}); - equal( innerHTML(frag.firstChild), "Meyer", "rendered right"); + assert.equal( innerHTML(frag.firstChild), "Meyer", "rendered right"); }); var template = stache("{{last}}") @@ -5199,11 +5199,11 @@ function makeTest(name, doc, mutation) { }); testHelpers.dev.devOnlyTest("warn when using on:, :to:on:, :to, :from or :bind without importing can-stache-bindings (#273)", function(assert) { - stop(); - expect(6); + var done = assert.async(); + assert.expect(6); var teardown = testHelpers.dev.willWarn(/unknown attribute binding/, function(message, matched) { if(matched) { - QUnit.ok(matched, message); + assert.ok(matched, message); } }); clone({ @@ -5215,15 +5215,15 @@ function makeTest(name, doc, mutation) { .import('can-stache') .then(function(stache) { stache('a link'); - QUnit.equal(teardown(), 5, "Every type of warning logged"); - start(); + assert.equal(teardown(), 5, "Every type of warning logged"); + done(); }); }); - testHelpers.dev.devOnlyTest("Don't warn about tag mismatch for Call expressions with dots in the method lookup (#214)", function() { + testHelpers.dev.devOnlyTest("Don't warn about tag mismatch for Call expressions with dots in the method lookup (#214)", function (assert) { var teardown = testHelpers.dev.willWarn(/unexpected closing tag/, function(message, matched) { if(matched) { - QUnit.ok(false, "Should not have warned about matching tags"); + assert.ok(false, "Should not have warned about matching tags"); } }); stache( @@ -5232,10 +5232,10 @@ function makeTest(name, doc, mutation) { '{{/games.getAvailableCourts}}' ); - QUnit.equal(teardown(), 0, "No warnings fired"); + assert.equal(teardown(), 0, "No warnings fired"); }); - test('Bracket expression after `this` (canjs/can-stache/issues/173)', function () { + QUnit.test('Bracket expression after `this` (canjs/can-stache/issues/173)', function(assert) { var template; var div = doc.createElement('div'); @@ -5250,19 +5250,19 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'James', 'correct value for this[bar]'); + assert.equal(innerHTML(p[0]), 'James', 'correct value for this[bar]'); data.set('bar', 'name.full'); - equal(innerHTML(p[0]), 'James Atherton', 'updated bar value for this[bar]'); + assert.equal(innerHTML(p[0]), 'James Atherton', 'updated bar value for this[bar]'); data.set('name.full', 'Lunch time'); - equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for this[bar]'); + assert.equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for this[bar]'); }); - test('Bracket expression with dot using DefineMap (canjs/can-stache/issues/173)', function () { + QUnit.test('Bracket expression with dot using DefineMap (canjs/can-stache/issues/173)', function(assert) { var template; var div = doc.createElement('div'); @@ -5276,16 +5276,16 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'James Atherton', 'correct value for this[bar]'); - equal(innerHTML(p[1]), 'James Atherton', 'correct value for this["name.full"]'); + assert.equal(innerHTML(p[0]), 'James Atherton', 'correct value for this[bar]'); + assert.equal(innerHTML(p[1]), 'James Atherton', 'correct value for this["name.full"]'); data['name.full'] = 'Lunch time'; - equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for this[bar]'); - equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for this["name.full"]'); + assert.equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for this[bar]'); + assert.equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for this["name.full"]'); }); - test('Bracket expression after `.` with dot using DefineMap (canjs/can-stache/issues/173)', function () { + QUnit.test('Bracket expression after `.` with dot using DefineMap (canjs/can-stache/issues/173)', function(assert) { var template; var div = doc.createElement('div'); @@ -5299,16 +5299,16 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'James Atherton', 'correct value for .[bar]'); - equal(innerHTML(p[1]), 'James Atherton', 'correct value for .["name.full"]'); + assert.equal(innerHTML(p[0]), 'James Atherton', 'correct value for .[bar]'); + assert.equal(innerHTML(p[1]), 'James Atherton', 'correct value for .["name.full"]'); data['name.full'] = 'Lunch time'; - equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for .[bar]'); - equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for .["name.full"]'); + assert.equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for .[bar]'); + assert.equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for .["name.full"]'); }); - test('Bracket expression by itself with dot using DefineMap (canjs/can-stache/issues/173)', function () { + QUnit.test('Bracket expression by itself with dot using DefineMap (canjs/can-stache/issues/173)', function(assert) { var template; var div = doc.createElement('div'); @@ -5328,22 +5328,22 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'James Atherton', 'correct value for [bar]'); - equal(innerHTML(p[1]), 'James Atherton', 'correct value for ["name.full"]'); - equal(innerHTML(p[2]), 'Yep yep', 'correct value for name.full'); - equal(innerHTML(p[3]), 'Tim Tim', 'correct value for ["name.full"] in a #with expression'); + assert.equal(innerHTML(p[0]), 'James Atherton', 'correct value for [bar]'); + assert.equal(innerHTML(p[1]), 'James Atherton', 'correct value for ["name.full"]'); + assert.equal(innerHTML(p[2]), 'Yep yep', 'correct value for name.full'); + assert.equal(innerHTML(p[3]), 'Tim Tim', 'correct value for ["name.full"] in a #with expression'); data['name.full'] = 'Lunch time'; data.name.full = 'Lunch time 2'; data.person["name.full"] = 'Lunch time 3'; - equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for [bar]'); - equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for ["name.full"]'); - equal(innerHTML(p[2]), 'Lunch time 2', 'updated value for name.full'); - equal(innerHTML(p[3]), 'Lunch time 3', 'updated value for ["name.full"] in a #with expression'); + assert.equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for [bar]'); + assert.equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for ["name.full"]'); + assert.equal(innerHTML(p[2]), 'Lunch time 2', 'updated value for name.full'); + assert.equal(innerHTML(p[3]), 'Lunch time 3', 'updated value for ["name.full"] in a #with expression'); }); - test('Bracket expression by itself with dot using can.Map (canjs/can-stache/issues/173)', function () { + QUnit.test('Bracket expression by itself with dot using can.Map (canjs/can-stache/issues/173)', function(assert) { var template; var div = doc.createElement('div'); @@ -5363,35 +5363,35 @@ function makeTest(name, doc, mutation) { div.appendChild(dom); var p = div.getElementsByTagName('p'); - equal(innerHTML(p[0]), 'James Atherton', 'correct value for [bar]'); - equal(innerHTML(p[1]), 'James Atherton', 'correct value for ["name.full"]'); - equal(innerHTML(p[2]), 'Yep yep', 'correct value for name.full'); - equal(innerHTML(p[3]), 'Tim Tim', 'correct value for ["name.full"] in a #with expression'); + assert.equal(innerHTML(p[0]), 'James Atherton', 'correct value for [bar]'); + assert.equal(innerHTML(p[1]), 'James Atherton', 'correct value for ["name.full"]'); + assert.equal(innerHTML(p[2]), 'Yep yep', 'correct value for name.full'); + assert.equal(innerHTML(p[3]), 'Tim Tim', 'correct value for ["name.full"] in a #with expression'); data.set('name.full', 'Lunch time'); data.get("name2").set("full", 'Lunch time 2'); data.get("person").set("name.full", 'Lunch time 3'); - equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for [bar]'); - equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for ["name.full"]'); - equal(innerHTML(p[2]), 'Lunch time 2', 'updated value for name.full'); - equal(innerHTML(p[3]), 'Lunch time 3', 'updated value for ["name.full"] in a #with expression'); + assert.equal(innerHTML(p[0]), 'Lunch time', 'updated `name.full` value for [bar]'); + assert.equal(innerHTML(p[1]), 'Lunch time', 'updated `name.full` value for ["name.full"]'); + assert.equal(innerHTML(p[2]), 'Lunch time 2', 'updated value for name.full'); + assert.equal(innerHTML(p[3]), 'Lunch time 3', 'updated value for ["name.full"] in a #with expression'); }); - test("newline is a valid special tag white space", function() { + QUnit.test("newline is a valid special tag white space", function(assert) { var renderer = stache('peekaboo
                  '); var html = renderer({ hideIt: true }); - QUnit.ok(html, "markup was generated"); + assert.ok(html, "markup was generated"); // almost the same, but no leading spaces before {{#unless renderer = stache('peekaboo
                  '); html = renderer({ hideIt: true }); - QUnit.ok(html, "markup was generated"); + assert.ok(html, "markup was generated"); }); - test("numbers can be used as hash keys (#203)", function() { + QUnit.test("numbers can be used as hash keys (#203)", function(assert) { stache.registerHelper("globalValue", function(prop, options) { return prop + ":" + (options.hash[0] || options.hash.zero); }); @@ -5401,7 +5401,7 @@ function makeTest(name, doc, mutation) { var fraghtml = innerHTML(frag.lastChild); - equal(fraghtml, "value:indexed"); + assert.equal(fraghtml, "value:indexed"); // sanity check -- exact same thing should work for string key here renderer = stache("

                  {{globalValue 'value' zero='strung'}}

                  "); @@ -5409,10 +5409,10 @@ function makeTest(name, doc, mutation) { fraghtml = innerHTML(frag.lastChild); - equal(fraghtml, "value:strung"); + assert.equal(fraghtml, "value:strung"); }); - test("Can assign multiple keys using with (#274)", function() { + QUnit.test("Can assign multiple keys using with (#274)", function(assert) { var viewModel = new DefineMap({ person: { first: "John", @@ -5429,8 +5429,8 @@ function makeTest(name, doc, mutation) { var view = renderer(viewModel); - equal(view.firstChild.firstChild.nodeValue, "John", "Got the first name"); - equal(view.firstChild.nextSibling.firstChild.nodeValue, "Gardner", "Got the last name"); + assert.equal(view.firstChild.firstChild.nodeValue, "John", "Got the first name"); + assert.equal(view.firstChild.nextSibling.firstChild.nodeValue, "Gardner", "Got the last name"); // second case: object AND hash values @@ -5443,13 +5443,13 @@ function makeTest(name, doc, mutation) { view = renderer(viewModel); - equal(view.firstChild.firstChild.nodeValue, "John", "Object AND hash values - Got the first name"); - equal(view.firstChild.nextSibling.firstChild.nodeValue, "Gardner", "Object AND hash values - Got the last name"); + assert.equal(view.firstChild.firstChild.nodeValue, "John", "Object AND hash values - Got the first name"); + assert.equal(view.firstChild.nextSibling.firstChild.nodeValue, "Gardner", "Object AND hash values - Got the last name"); }); - test("can assign hash using each #300", function () { + QUnit.test("can assign hash using each #300", function(assert) { var viewModel = new DefineMap({ people: [{ first: "John", @@ -5472,11 +5472,11 @@ function makeTest(name, doc, mutation) { var view = renderer(viewModel); - equal(view.lastChild.getAttribute('data-index'), "2", "Got the index"); - equal(view.firstChild.nextSibling.firstChild.firstChild.nodeValue, "John", "Got aliased value"); + assert.equal(view.lastChild.getAttribute('data-index'), "2", "Got the index"); + assert.equal(view.firstChild.nextSibling.firstChild.firstChild.nodeValue, "John", "Got aliased value"); }); - test("can assign hash using each on an iterable map #300", function () { + QUnit.test("can assign hash using each on an iterable map #300", function(assert) { var viewModel = new DefineMap({ flags: { isJSCool: "yep", @@ -5492,16 +5492,16 @@ function makeTest(name, doc, mutation) { var view = renderer(viewModel); - equal(view.firstChild.firstChild.nodeValue, "isJSCool", "Got the key"); - equal(view.firstChild.lastChild.nodeValue, "yep", "Got aliased value"); + assert.equal(view.firstChild.firstChild.nodeValue, "isJSCool", "Got the key"); + assert.equal(view.firstChild.lastChild.nodeValue, "yep", "Got aliased value"); }); - test('check if is already registred #165', function () { - stop(); + QUnit.test('check if is already registred #165', function(assert) { + var done = assert.async(); viewCallbacks.tag("content", function() {}); var teardown = testHelpers.dev.willWarn(/Custom tag: content is already defined/, function(message, matched) { - QUnit.notOk(matched, message); + assert.notOk(matched, message); }); clone({ @@ -5510,18 +5510,18 @@ function makeTest(name, doc, mutation) { .import('can-stache') .then(function(stache) { stache('foo'); - QUnit.equal(teardown(), 0, "Warning was not logged"); - start(); + assert.equal(teardown(), 0, "Warning was not logged"); + done(); }); }); - testHelpers.dev.devOnlyTest("partials warn on missing context (#328)", function() { - stop(); + testHelpers.dev.devOnlyTest("partials warn on missing context (#328)", function (assert) { + var done = assert.async(); var teardown = testHelpers.dev.willWarn(/is not defined in the scope/, function(message, matched) { if(matched) { - QUnit.ok(true, "Warning fired"); - QUnit.equal(teardown(), 1, "One matching warning fired"); - start(); + assert.ok(true, "Warning fired"); + assert.equal(teardown(), 1, "One matching warning fired"); + done(); } }); @@ -5529,7 +5529,7 @@ function makeTest(name, doc, mutation) { renderer({ foo: stache("baz") }); }); - test("#unless works with call expressions", function(){ + QUnit.test("#unless works with call expressions", function(assert) { var template = stache("{{#unless(foo)}}foo{{else}}bar{{/unless}}"); var map = new DefineMap({ foo: false @@ -5538,22 +5538,22 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "foo"); + assert.equal(innerHTML(div), "foo"); map.foo = true; - QUnit.equal(innerHTML(div), "bar"); + assert.equal(innerHTML(div), "bar"); }); - test("log works with call expressions", function(){ + QUnit.test("log works with call expressions", function(assert) { var map = new DefineMap({ foo: "bar" }); var log = console.log; - QUnit.stop(); + var done = assert.async(); console.log = function(value){ - QUnit.equal(value, map); - console.log = log; - QUnit.start(); + assert.equal(value, map); + console.log = QUnit.log; + done(); }; var template = stache("{{console.log(this)}}"); @@ -5563,7 +5563,7 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); }); - test("debugger works with call expressions", function(){ + QUnit.test("debugger works with call expressions", function(assert) { debug.__testing.allowDebugger = false; var log = canLog.log; var warn = canLog.warn; @@ -5573,7 +5573,7 @@ function makeTest(name, doc, mutation) { "Forgotten {{debugger}} helper" ]; canLog.log = canLog.warn = function(message){ - QUnit.equal(message, logs.shift()); + assert.equal(message, logs.shift()); } var template = stache("{{debugger()}}"); @@ -5582,12 +5582,12 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - canLog.log = log; + canLog.log = QUnit.log; canLog.warn = warn; debug.__testing.allowDebugger = true; }); - test("debugger Lookup Expression calls debugger helper (#469)", function(){ + QUnit.test("debugger Lookup Expression calls debugger helper (#469)", function(assert) { debug.__testing.allowDebugger = false; var log = canLog.log; var warn = canLog.warn; @@ -5597,7 +5597,7 @@ function makeTest(name, doc, mutation) { "Forgotten {{debugger}} helper" ]; canLog.log = canLog.warn = function(message){ - QUnit.equal(message, logs.shift()); + assert.equal(message, logs.shift()); } var template = stache("{{debugger}}"); @@ -5606,12 +5606,12 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - canLog.log = log; + canLog.log = QUnit.log; canLog.warn = warn; debug.__testing.allowDebugger = true; }); - test("#switch, #case, and #default work with call expressions", function(){ + QUnit.test("#switch, #case, and #default work with call expressions", function(assert) { var template = stache("{{#switch(type)}}{{#case('admin')}}admin{{/case}}{{#default()}}peasant{{/default}}{{/switch}}"); var map = new DefineMap({ type: "admin" @@ -5620,12 +5620,12 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "admin"); + assert.equal(innerHTML(div), "admin"); map.type = "peasant"; - QUnit.equal(innerHTML(div), "peasant"); + assert.equal(innerHTML(div), "peasant"); }); - test("joinbase works with call expressions", function(){ + QUnit.test("joinbase works with call expressions", function(assert) { var baseUrl = System.baseURL || getBaseURL(); var template = stache("{{joinBase('hello/', name, '.png')}}"); var map = new DefineMap({ @@ -5635,10 +5635,10 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), joinURIs(baseUrl, "hello/world.png")); + assert.equal(innerHTML(div), joinURIs(baseUrl, "hello/world.png")); }); - test("#each works with hash expression in call expression", function(){ + QUnit.test("#each works with hash expression in call expression", function(assert) { var template = stache("{{#each(todos, todo=value num=index)}}

                  {{todo.name}}

                  {{/each}}"); var map = new DefineMap({ todos: [ @@ -5657,12 +5657,12 @@ function makeTest(name, doc, mutation) { var p = div.getElementsByTagName("p"); for(var i = 0; i < p.length; i++){ - QUnit.equal(innerHTML(p[i]), map.todos[i].name); - QUnit.equal(p[i].getAttribute("data-index"), i); + assert.equal(innerHTML(p[i]), map.todos[i].name); + assert.equal(p[i].getAttribute("data-index"), i); } }); - test("#each with call expression should be optimized for performance", function(){ + QUnit.test("#each with call expression should be optimized for performance", function(assert) { var div = doc.createElement('div'); var count = 0; @@ -5676,16 +5676,16 @@ function makeTest(name, doc, mutation) { var frag = template(listCompute); div.appendChild(frag); - QUnit.equal(innerHTML(div), "one two "); + assert.equal(innerHTML(div), "one two "); listCompute.set(["one", "two", "three"]); - QUnit.equal(innerHTML(div), "one two three "); + assert.equal(innerHTML(div), "one two three "); - QUnit.equal(count, 1, "#each helper should only be called once"); + assert.equal(count, 1, "#each helper should only be called once"); overwriteGlobalHelper('each', origEach); }); - test("#each(asyncGetter) should only call async getter once (#402)", function(){ + QUnit.test("#each(asyncGetter) should only call async getter once (#402)", function(assert) { var div = doc.createElement('div'); var count = 0; var RESOLVE; @@ -5714,20 +5714,20 @@ function makeTest(name, doc, mutation) { var frag = template(data); div.appendChild(frag); - QUnit.equal(innerHTML(div), "", "initially empty"); + assert.equal(innerHTML(div), "", "initially empty"); - QUnit.stop(); + var done = assert.async(); promise.then(function() { // setTimeout so DOM will update setTimeout(function() { - QUnit.equal(innerHTML(div), "one two three ", "one two three "); - QUnit.equal(count, 1, "AsyncObservable should only be called once"); - QUnit.start(); + assert.equal(innerHTML(div), "one two three ", "one two three "); + assert.equal(count, 1, "AsyncObservable should only be called once"); + done(); }, 10); }); }); - test("#with works with hash expression in call expression", function(){ + QUnit.test("#with works with hash expression in call expression", function(assert) { var template = stache("{{#with(bar=foo qux=baz)}}{{bar}} {{qux}}{{/with}}"); var map = new DefineMap({ foo: "hello", @@ -5737,10 +5737,10 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), map.foo + " " + map.baz); + assert.equal(innerHTML(div), map.foo + " " + map.baz); }); - test("#with works with hash expression and objects in call expression", function(){ + QUnit.test("#with works with hash expression and objects in call expression", function(assert) { var template = stache("{{#with(bar=foo qux=baz)}}{{bar}} {{qux}}{{/with}}"); var map = { foo: "hello", @@ -5750,18 +5750,18 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), map.foo + " " + map.baz); + assert.equal(innerHTML(div), map.foo + " " + map.baz); }); - test("call expression works with hash expression", function(){ + QUnit.test("call expression works with hash expression", function(assert) { var exprData = core.expression.parse("helper(todos, todo=value num=index)"); var args = core.expression.Call.prototype.args.call(exprData, new Scope({})); - equal(args().hashExprs.todo.key, "value"); - equal(args().hashExprs.num.key, "index"); + assert.equal(args().hashExprs.todo.key, "value"); + assert.equal(args().hashExprs.num.key, "index"); }); - test("#each with hash expression in call expression should not warn", function(){ + QUnit.test("#each with hash expression in call expression should not warn", function(assert) { var template = stache("{{#each(todos, todo=value)}}

                  {{todo}}

                  {{/each}}"); var map = new DefineMap({todos: ["foo", "bar", "baz"]}); var warn1 = testHelpers.dev.willWarn(/can-stache: Using the `as`/i); @@ -5769,12 +5769,12 @@ function makeTest(name, doc, mutation) { template(map); - equal(warn1(), 0); - equal(warn2(), 0); + assert.equal(warn1(), 0); + assert.equal(warn2(), 0); }); - test('#each with call expression and arrays should work with hash expressions', function(){ + QUnit.test('#each with call expression and arrays should work with hash expressions', function(assert) { var list = ['foo', 'bar', 'baz']; var template = stache('{{#each(this, item=value, itemIndex=index)}}{{itemIndex}}:{{item}}{{/each}}'); var div = doc.createElement('div'); @@ -5782,10 +5782,10 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - equal(innerHTML(div), '0:foo1:bar2:baz'); + assert.equal(innerHTML(div), '0:foo1:bar2:baz'); }); - test('#each with call expression and objects should work with hash expressions', function(){ + QUnit.test('#each with call expression and objects should work with hash expressions', function(assert) { var map = {'foo': 'bar', 'baz': 'qux'}; var template = stache('{{#each(this, itemKey=key itemValue=value)}}{{itemKey}}:{{itemValue}}{{/each}}'); var div = doc.createElement('div'); @@ -5793,18 +5793,18 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - equal(innerHTML(div), 'foo:barbaz:qux'); + assert.equal(innerHTML(div), 'foo:barbaz:qux'); }); - testHelpers.dev.devOnlyTest("scope has lineNumber", function(){ + testHelpers.dev.devOnlyTest("scope has lineNumber", function (assert){ var template = stache('

                  {{scope.lineNumber}}

                  \n

                  {{scope.lineNumber}}

                  '); var frag = template(); - equal(frag.firstChild.firstChild.nodeValue, '1'); - equal(frag.lastChild.firstChild.nodeValue, '2'); + assert.equal(frag.firstChild.firstChild.nodeValue, '1'); + assert.equal(frag.lastChild.firstChild.nodeValue, '2'); }); - QUnit.test("using scope.index works when using #each with arrays", function() { + QUnit.test("using scope.index works when using #each with arrays", function(assert) { var data = { itemsArray: [ "zero", "one", "two" ] }; @@ -5823,12 +5823,12 @@ function makeTest(name, doc, mutation) { var lis = div.getElementsByTagName('li'); - QUnit.equal( innerHTML(lis[0]), "0: zero" ); - QUnit.equal( innerHTML(lis[1]), "1: one" ); - QUnit.equal( innerHTML(lis[2]), "2: two" ); + assert.equal( innerHTML(lis[0]), "0: zero" ); + assert.equal( innerHTML(lis[1]), "1: one" ); + assert.equal( innerHTML(lis[2]), "2: two" ); }); - QUnit.test("using scope.key works when using #each with DefineMap", function() { + QUnit.test("using scope.key works when using #each with DefineMap", function(assert) { var data = new DefineMap({ itemsObj: { zero: 0, @@ -5851,12 +5851,12 @@ function makeTest(name, doc, mutation) { var lis = div.getElementsByTagName('li'); - QUnit.equal( innerHTML(lis[0]), "zero: 0" ); - QUnit.equal( innerHTML(lis[1]), "one: 1" ); - QUnit.equal( innerHTML(lis[2]), "two: 2" ); + assert.equal( innerHTML(lis[0]), "zero: 0" ); + assert.equal( innerHTML(lis[1]), "one: 1" ); + assert.equal( innerHTML(lis[2]), "two: 2" ); }); - QUnit.test("using scope.key works when using #each with SimpleMap", function() { + QUnit.test("using scope.key works when using #each with SimpleMap", function(assert) { var itemsObj = new SimpleMap({ zero: 0, one: 1, @@ -5877,12 +5877,12 @@ function makeTest(name, doc, mutation) { var lis = div.getElementsByTagName('li'); - QUnit.equal( innerHTML(lis[0]), "zero: 0" ); - QUnit.equal( innerHTML(lis[1]), "one: 1" ); - QUnit.equal( innerHTML(lis[2]), "two: 2" ); + assert.equal( innerHTML(lis[0]), "zero: 0" ); + assert.equal( innerHTML(lis[1]), "one: 1" ); + assert.equal( innerHTML(lis[2]), "two: 2" ); }); - QUnit.test("using scope.key works when using #each with objects", function() { + QUnit.test("using scope.key works when using #each with objects", function(assert) { var itemsObj = { zero: 0, one: 1, @@ -5903,12 +5903,12 @@ function makeTest(name, doc, mutation) { var lis = div.getElementsByTagName('li'); - QUnit.equal( innerHTML(lis[0]), "zero: 0" ); - QUnit.equal( innerHTML(lis[1]), "one: 1" ); - QUnit.equal( innerHTML(lis[2]), "two: 2" ); + assert.equal( innerHTML(lis[0]), "zero: 0" ); + assert.equal( innerHTML(lis[1]), "one: 1" ); + assert.equal( innerHTML(lis[2]), "two: 2" ); }); - QUnit.test("using scope.index works when using #array", function() { + QUnit.test("using scope.index works when using #array", function(assert) { var data = new DefineMap({ itemsArray: [ "zero", "one", "two" ] }); @@ -5927,12 +5927,12 @@ function makeTest(name, doc, mutation) { var lis = div.getElementsByTagName('li'); - QUnit.equal( innerHTML(lis[0]), "0: zero" ); - QUnit.equal( innerHTML(lis[1]), "1: one" ); - QUnit.equal( innerHTML(lis[2]), "2: two" ); + assert.equal( innerHTML(lis[0]), "0: zero" ); + assert.equal( innerHTML(lis[1]), "1: one" ); + assert.equal( innerHTML(lis[2]), "2: two" ); }); - QUnit.test("values can be read from the scope passed to a stache renderer using {{scope.root}}", function() { + QUnit.test("values can be read from the scope passed to a stache renderer using {{scope.root}}", function(assert) { var data = new DefineMap({ itemsArray: [ "zero", "one", "two" ], exclamation: "!!!" @@ -5952,12 +5952,12 @@ function makeTest(name, doc, mutation) { var lis = div.getElementsByTagName('li'); - QUnit.equal( innerHTML(lis[0]), "zero!!!" ); - QUnit.equal( innerHTML(lis[1]), "one!!!" ); - QUnit.equal( innerHTML(lis[2]), "two!!!" ); + assert.equal( innerHTML(lis[0]), "zero!!!" ); + assert.equal( innerHTML(lis[1]), "one!!!" ); + assert.equal( innerHTML(lis[2]), "two!!!" ); }); - QUnit.test("scope.index works after updating the source list", function(){ + QUnit.test("scope.index works after updating the source list", function(assert) { var div = doc.createElement('div'); var list = new DefineList(["a", "c", "d", "e", "f"]); var template = stache("{{#each(this)}}{{scope.index}}{{/each}}"); @@ -5967,46 +5967,46 @@ function makeTest(name, doc, mutation) { list.splice(1, 0, "b") - QUnit.equal(innerHTML(div), "012345"); + assert.equal(innerHTML(div), "012345"); }); - testHelpers.dev.devOnlyTest("section iteration of property using bracket notation should not warn about unexpected closing tag", function (){ + testHelpers.dev.devOnlyTest("section iteration of property using bracket notation should not warn about unexpected closing tag", function (assert){ var teardown = testHelpers.dev.willWarn(/unexpected closing tag/); stache("{{#items['foo:bar']}}{{this}}{{/items}}"); - equal(teardown(), 0); + assert.equal(teardown(), 0); }); - testHelpers.dev.devOnlyTest("passing bracket notation to method should not warn about unexpected closing tag", function (){ + testHelpers.dev.devOnlyTest("passing bracket notation to method should not warn about unexpected closing tag", function (assert){ var teardown = testHelpers.dev.willWarn(/unexpected closing tag/); stache("{{#eq(items['foo:bar'], 'baz')}}qux{{/eq}}"); - equal(teardown(), 0); + assert.equal(teardown(), 0); }); - testHelpers.dev.devOnlyTest("reading current scope with bracket notation should not warn about unexpected closing tag", function (){ + testHelpers.dev.devOnlyTest("reading current scope with bracket notation should not warn about unexpected closing tag", function (assert){ var teardown = testHelpers.dev.willWarn(/unexpected closing tag/); stache("{{#['foo:bar']}}qux{{/['foo:bar']}}"); - equal(teardown(), 0); + assert.equal(teardown(), 0); }); - testHelpers.dev.devOnlyTest("section iteration of property using bracket notation should warn about unexpected closing tag", function (){ + testHelpers.dev.devOnlyTest("section iteration of property using bracket notation should warn about unexpected closing tag", function (assert){ var teardown = testHelpers.dev.willWarn("1: unexpected closing tag {{/items['foo:bar']}} expected {{/items}}"); stache("{{#items['foo:bar']}}{{this}}{{/items['foo:bar']}}"); - equal(teardown(), 1); + assert.equal(teardown(), 1); }); - testHelpers.dev.devOnlyTest("lineNumber should be set on the scope at 'end' before passing it to viewCallbacks.tagHandler (#373)", function (){ + testHelpers.dev.devOnlyTest("lineNumber should be set on the scope at 'end' before passing it to viewCallbacks.tagHandler (#373)", function (assert){ var tagHandler = viewCallbacks.tagHandler; viewCallbacks.tagHandler = function (context, tagName, options){ - equal(options.scope.peek('scope.lineNumber'), 3); + assert.equal(options.scope.peek('scope.lineNumber'), 3); } stache("foo\nbar\n\nbaz")(); @@ -6014,11 +6014,11 @@ function makeTest(name, doc, mutation) { viewCallbacks.tagHandler = tagHandler; }); - testHelpers.dev.devOnlyTest("lineNumber should be set on the scope at 'close' before passing it to viewCallbacks.tagHandler (#373)", function (){ + testHelpers.dev.devOnlyTest("lineNumber should be set on the scope at 'close' before passing it to viewCallbacks.tagHandler (#373)", function (assert){ var tagHandler = viewCallbacks.tagHandler; viewCallbacks.tagHandler = function (context, tagName, options){ - equal(options.scope.peek('scope.lineNumber'), 3); + assert.equal(options.scope.peek('scope.lineNumber'), 3); } stache("foo\nbar\n\nbaz")(); @@ -6026,11 +6026,11 @@ function makeTest(name, doc, mutation) { viewCallbacks.tagHandler = tagHandler; }); - testHelpers.dev.devOnlyTest("lineNumber should be set on the scope at 'attrEnd' before passing it to viewCallbacks.tagHandler (#373)", function (){ + testHelpers.dev.devOnlyTest("lineNumber should be set on the scope at 'attrEnd' before passing it to viewCallbacks.tagHandler (#373)", function (assert){ var attribute = 'toProp:from'; var encodedAttribute = encoder.encode(attribute); viewCallbacks.attr(encodedAttribute, function (el, attrData){ - equal(attrData.scope.peek('scope.lineNumber'), 3); + assert.equal(attrData.scope.peek('scope.lineNumber'), 3); }); stache("foo\nbar\n
                  \nbaz")(); @@ -6039,11 +6039,11 @@ function makeTest(name, doc, mutation) { delete viewCallbacks._attributes[encodedAttribute]; }); - QUnit.test("{{bar}} should not call `bar`", function(){ + QUnit.test("{{bar}} should not call `bar`", function(assert) { var div = doc.createElement('div'); var data = { bar: function() { - QUnit.ok(false, 'bar should not be called'); + assert.ok(false, 'bar should not be called'); return 'bar value'; } }; @@ -6052,14 +6052,14 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - QUnit.equal(innerHTML(div), data.bar.bind(data).toString()); + assert.equal(innerHTML(div), data.bar.bind(data).toString()); }); - QUnit.test("{{bar 'foo'}} should call `bar` and pass 'foo'", function(){ + QUnit.test("{{bar 'foo'}} should call `bar` and pass 'foo'", function(assert) { var div = doc.createElement('div'); var data = { bar: function(key) { - QUnit.ok(true, 'bar should be called'); + assert.ok(true, 'bar should be called'); return key; } }; @@ -6068,26 +6068,26 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - QUnit.equal(innerHTML(div), "foo"); + assert.equal(innerHTML(div), "foo"); }); - QUnit.test('#scope.helpers can be used to call a built-in helper if the scope has a property of the same name', function(){ + QUnit.test('#scope.helpers can be used to call a built-in helper if the scope has a property of the same name', function(assert) { var template = stache('{{#scope.helpers.if truthy}}truthy{{else}}falsey{{/scope.helpers.if}}'); var div = doc.createElement('div'); var frag = template({ truthy: true, if: function(val) { - QUnit.ok(false, 'should not be called'); + assert.ok(false, 'should not be called'); return false; } }); div.appendChild(frag); - equal(innerHTML(div), 'truthy'); + assert.equal(innerHTML(div), 'truthy'); }); - QUnit.test('functions called on nested observables should have the correct context', function() { + QUnit.test('functions called on nested observables should have the correct context', function(assert) { var person = new DefineMap({ name: "Mick", getName: function(msg) { @@ -6105,21 +6105,21 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - equal(innerHTML(div), 'Mick', 'works with Call Expressions'); + assert.equal(innerHTML(div), 'Mick', 'works with Call Expressions'); div = doc.createElement("div"); template = stache("{{person.getName 'Hello '}}"); frag = template(data); div.appendChild(frag); - equal(innerHTML(div), 'Hello Mick'); + assert.equal(innerHTML(div), 'Hello Mick'); }); - QUnit.test("tag callbacks get called with directly nested data", function(){ + QUnit.test("tag callbacks get called with directly nested data", function(assert) { var expectedResult, testMessage; viewCallbacks.tag("directly-nested-test", function(el, tagData){ - QUnit.equal(tagData.directlyNested, expectedResult, testMessage); + assert.equal(tagData.directlyNested, expectedResult, testMessage); }); expectedResult = true; @@ -6142,15 +6142,15 @@ function makeTest(name, doc, mutation) { }); - QUnit.test("Can call helpers (helper expressions) within attributes", function(){ + QUnit.test("Can call helpers (helper expressions) within attributes", function(assert) { var vm = { name: function(first) { return first; } }; var frag = stache("
                  ")(vm); - QUnit.equal(frag.firstChild.getAttribute("id"), "matthew", "able to set the attribute"); + assert.equal(frag.firstChild.getAttribute("id"), "matthew", "able to set the attribute"); }); - test("#case and #default should not change context (#475)", function(){ + QUnit.test("#case and #default should not change context (#475)", function(assert) { var template = stache("{{#switch(type)}}{{#case('admin')}}admin: {{name}}{{/case}}{{#default()}}peasant: {{name}}{{/default}}{{/switch}}"); var map = new DefineMap({ name: "Johnny", @@ -6160,12 +6160,12 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "admin: Johnny", "{{#case('Johnny')}}"); + assert.equal(innerHTML(div), "admin: Johnny", "{{#case('Johnny')}}"); map.type = "peasant"; - QUnit.equal(innerHTML(div), "peasant: Johnny", "{{#default()}}"); + assert.equal(innerHTML(div), "peasant: Johnny", "{{#default()}}"); }); - test("#case and #default with Helper Expressions should not change context (#475)", function(){ + QUnit.test("#case and #default with Helper Expressions should not change context (#475)", function(assert) { var template = stache("{{#switch type}}{{#case 'admin'}}admin: {{name}}{{/case}}{{#default}}peasant: {{name}}{{/default}}{{/switch}}"); var map = new DefineMap({ name: "Johnny", @@ -6175,50 +6175,50 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "admin: Johnny", "{{#case 'Johnny'}}"); + assert.equal(innerHTML(div), "admin: Johnny", "{{#case 'Johnny'}}"); map.type = "peasant"; - QUnit.equal(innerHTML(div), "peasant: Johnny", "{{#default}}"); + assert.equal(innerHTML(div), "peasant: Johnny", "{{#default}}"); }); - QUnit.test("Can use magic tags within attributes (#470)", function(){ + QUnit.test("Can use magic tags within attributes (#470)", function(assert) { var vm = new DefineMap({ name: "" }); var frag = stache("")(vm); - QUnit.equal(frag.firstChild.value, "", "initially empty"); + assert.equal(frag.firstChild.value, "", "initially empty"); vm.name = "matthew"; - QUnit.equal(frag.firstChild.value, "matthew", "set to matthew"); + assert.equal(frag.firstChild.value, "matthew", "set to matthew"); frag.firstChild.value = "mark" - QUnit.equal(frag.firstChild.value, "mark", "set to mark"); + assert.equal(frag.firstChild.value, "mark", "set to mark"); vm.name = "paul"; - QUnit.equal(frag.firstChild.value, "paul", "set to paul"); + assert.equal(frag.firstChild.value, "paul", "set to paul"); }); - testHelpers.dev.devOnlyTest("Can use magic tags within attributes without warnings (#477)", function(){ + testHelpers.dev.devOnlyTest("Can use magic tags within attributes without warnings (#477)", function (assert){ var teardown = testHelpers.dev.willWarn(/Unable to find helper/); var vm = new DefineMap({ name: "" }); stache("")(vm); - QUnit.equal(teardown(), 0, "no warning"); + assert.equal(teardown(), 0, "no warning"); }); - testHelpers.dev.devOnlyTest("{{data}} helper shows deprecation warning", function () { + testHelpers.dev.devOnlyTest("{{data}} helper shows deprecation warning", function (assert) { var teardown = testHelpers.dev.willWarn(/{{data}} helper has been deprecated; use {{domData}} instead/, function(message, matched) { if (matched) { - ok(true, "received warning"); + assert.ok(true, "received warning"); } }); stache("")(); - QUnit.equal(teardown(), 1, "Exactly one warning called"); + assert.equal(teardown(), 1, "Exactly one warning called"); }); - test("missing partial error (#506)", function(){ + QUnit.test("missing partial error (#506)", function(assert) { var map = new SimpleMap({}); @@ -6226,16 +6226,16 @@ function makeTest(name, doc, mutation) { var frag = renderer(map); - QUnit.ok(true, "no error"); - QUnit.equal( innerHTML(frag.firstChild), "", "no content"); + assert.ok(true, "no error"); + assert.equal( innerHTML(frag.firstChild), "", "no content"); map.set("foo", function(){ return "bar"; }); - QUnit.equal( innerHTML(frag.firstChild), "bar", "updated to bar"); + assert.equal( innerHTML(frag.firstChild), "bar", "updated to bar"); }); - test("each should premptively bind values", function(){ + QUnit.test("each should premptively bind values", function(assert) { var calls = 0; var template = stache("{{#each(someMethod())}}
                  {{/each}}"); @@ -6255,8 +6255,8 @@ function makeTest(name, doc, mutation) { } }); - QUnit.equal(methodCalls, 1, "one method call"); - QUnit.equal(calls, 1, "one observation call"); + assert.equal(methodCalls, 1, "one method call"); + assert.equal(calls, 1, "one observation call"); }); QUnit.test("render objects with can.viewInsert symbol (#502)", function(assert) { @@ -6273,7 +6273,7 @@ function makeTest(name, doc, mutation) { assert.equal(innerHTML(fragment.firstChild), "Hello world", "fragment has correct text content"); }); - test("addHelper can take an object of helpers", function(){ + QUnit.test("addHelper can take an object of helpers", function(assert) { var helpers = { helperOne: function(){ return "one"; @@ -6290,11 +6290,11 @@ function makeTest(name, doc, mutation) { var spanOne = frag.firstChild; var spanTwo = spanOne.nextSibling; - QUnit.equal(spanOne.firstChild.nodeValue, "one"); - QUnit.equal(spanTwo.firstChild.nodeValue, "two"); + assert.equal(spanOne.firstChild.nodeValue, "one"); + assert.equal(spanTwo.firstChild.nodeValue, "two"); }); - test("addBindings takes a map of bindings", function(){ + QUnit.test("addBindings takes a map of bindings", function(assert) { var map = new Map(); map.set("foo", function(el, attrData) { el.appendChild(DOCUMENT().createTextNode("foo")); @@ -6310,11 +6310,11 @@ function makeTest(name, doc, mutation) { var firstSpan = frag.firstChild; var secondSpan = firstSpan.nextSibling; - QUnit.equal(firstSpan.firstChild.nodeValue, "foo"); - QUnit.equal(secondSpan.firstChild.nodeValue, "bar"); + assert.equal(firstSpan.firstChild.nodeValue, "foo"); + assert.equal(secondSpan.firstChild.nodeValue, "bar"); }); - test("addBindings will use can.callbackMap symbol if available.", function(){ + QUnit.test("addBindings will use can.callbackMap symbol if available.", function(assert) { var map = new Map(); map.set("foo2", function(el, attrData) { el.appendChild(DOCUMENT().createTextNode("foo")); @@ -6335,11 +6335,11 @@ function makeTest(name, doc, mutation) { var firstSpan = frag.firstChild; var secondSpan = firstSpan.nextSibling; - QUnit.equal(firstSpan.firstChild.nodeValue, "foo"); - QUnit.equal(secondSpan.firstChild.nodeValue, "bar"); + assert.equal(firstSpan.firstChild.nodeValue, "foo"); + assert.equal(secondSpan.firstChild.nodeValue, "bar"); }); - test("able to put in helpers without overwriting them", function(){ + QUnit.test("able to put in helpers without overwriting them", function(assert) { var template = stache("{{foo()}}"); var foo = function(){ return "foo" }; @@ -6353,12 +6353,12 @@ function makeTest(name, doc, mutation) { foo: function(){ return "bar" } } } ); - QUnit.equal( templateContext.helpers.get("foo"), foo ); + assert.equal( templateContext.helpers.get("foo"), foo ); }); - QUnit.test("nested expressions get the right number of arguments (#581)", function(){ + QUnit.test("nested expressions get the right number of arguments (#581)", function(assert) { stache.addHelper( "argumentsLength", function() { - QUnit.equal(arguments.length, 2, "got the right number of arguments") + assert.equal(arguments.length, 2, "got the right number of arguments") return arguments.length; } ); @@ -6370,7 +6370,7 @@ function makeTest(name, doc, mutation) { }); - QUnit.test("null does not trigger unescape (#600)", function(){ + QUnit.test("null does not trigger unescape (#600)", function(assert) { var map = new SimpleMap({ foo: null @@ -6378,11 +6378,11 @@ function makeTest(name, doc, mutation) { var frag = stache("
                  {{foo}}
                  ")(map); map.set("foo", "

                  "); - QUnit.equal( frag.firstChild.getElementsByTagName("p").length, 0, "no paragraphs"); + assert.equal( frag.firstChild.getElementsByTagName("p").length, 0, "no paragraphs"); }); - testHelpers.dev.devOnlyTest("Arrays warn about escaping (#600)", 3, function () { + testHelpers.dev.devOnlyTest("Arrays warn about escaping (#600)", 3, function (assert) { var map = new SimpleMap({ foo: ["

                  "] @@ -6390,7 +6390,7 @@ function makeTest(name, doc, mutation) { var teardown = testHelpers.dev.willWarn(/stache.safeString/, function(message, matched) { if(matched) { - ok(true, "received warning"); + assert.ok(true, "received warning"); } }); @@ -6398,7 +6398,7 @@ function makeTest(name, doc, mutation) { var frag = stache("
                  {{foo}}
                  ")(map); teardown(); - QUnit.equal( frag.firstChild.getElementsByTagName("p").length, 0, "no paragraphs"); + assert.equal( frag.firstChild.getElementsByTagName("p").length, 0, "no paragraphs"); map = new SimpleMap({ @@ -6407,11 +6407,11 @@ function makeTest(name, doc, mutation) { frag = stache("
                  {{foo}}
                  ")(map); - QUnit.equal( frag.firstChild.getElementsByTagName("p").length, 1, "paragraphs"); + assert.equal( frag.firstChild.getElementsByTagName("p").length, 1, "paragraphs"); }); - QUnit.test("SVGs are not rendered correctly", function() { + QUnit.test("SVGs are not rendered correctly", function(assert) { if(doc.createElementNS) { var svg = '' + '' + @@ -6423,15 +6423,15 @@ function makeTest(name, doc, mutation) { var svgTag = frag.firstChild; var useTag = frag.firstChild.getElementsByTagName('use')[0]; - QUnit.equal(svgTag.getAttributeNS("http://www.w3.org/2000/xmlns/", 'xmlns'), "http://www.w3.org/2000/svg", "xmlns attr"); - QUnit.equal(useTag.getAttributeNS("http://www.w3.org/1999/xlink", 'href'), "#h-shape", "xlink:href attr"); + assert.equal(svgTag.getAttributeNS("http://www.w3.org/2000/xmlns/", 'xmlns'), "http://www.w3.org/2000/svg", "xmlns attr"); + assert.equal(useTag.getAttributeNS("http://www.w3.org/1999/xlink", 'href'), "#h-shape", "xlink:href attr"); } else { - expect(0); + assert.expect(0); } }); - test("Handlebars helper: switch/case scope issue inside #each #509", function() { + QUnit.test("Handlebars helper: switch/case scope issue inside #each #509", function(assert) { var template = stache("{{#each(group, person=value)}}"+ "{{#switch(person.gender)}}"+ "{{#case 'male'}}{{person.name}}{{/case}}"+ @@ -6448,10 +6448,10 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div).trim(), 'matt'); + assert.equal(innerHTML(div).trim(), 'matt'); }); - QUnit.test("Literals in magic tags #615", function() { + QUnit.test("Literals in magic tags #615", function(assert) { var template = stache("
                  {{0}} - {{1}}
                  "); var map = new DefineMap({ "0": "Hello", @@ -6464,11 +6464,11 @@ function makeTest(name, doc, mutation) { section.appendChild(frag); var div = section.firstChild; - QUnit.equal(div.getAttribute('data-value'), 1, "has the literal value"); - QUnit.equal(innerHTML(div).trim(), '0 - 1'); + assert.equal(div.getAttribute('data-value'), 1, "has the literal value"); + assert.equal(innerHTML(div).trim(), '0 - 1'); }); - test("#if works with call expressions", function(){ + QUnit.test("#if works with call expressions", function(assert) { var template = stache("{{#if(foo)}}foo{{else}}bar{{/if}}"); var map = new DefineMap({ foo: true @@ -6477,12 +6477,12 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "foo"); + assert.equal(innerHTML(div), "foo"); map.foo = false; - QUnit.equal(innerHTML(div), "bar"); + assert.equal(innerHTML(div), "bar"); }); - test("#if works with nested call expressions", function(){ + QUnit.test("#if works with nested call expressions", function(assert) { var template = stache("{{#and({if(foo)}, if(bar))}}and{{else}}!and{{/and}} {{#or(if(foo), if(bar))}}or{{else}}!or{{/or}}"); var map = new DefineMap({ @@ -6493,18 +6493,18 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "and or"); + assert.equal(innerHTML(div), "and or"); map.foo = false; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = false; - QUnit.equal(innerHTML(div), "!and !or"); + assert.equal(innerHTML(div), "!and !or"); map.foo = true; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = true; - QUnit.equal(innerHTML(div), "and or"); + assert.equal(innerHTML(div), "and or"); }); - test("#unless works with nested call expressions", function(){ + QUnit.test("#unless works with nested call expressions", function(assert) { var template = stache("{{#and(unless(foo), unless(bar))}}and{{else}}!and{{/and}} {{#or(unless(foo), unless(bar))}}or{{else}}!or{{/or}}"); var map = new DefineMap({ foo: true, @@ -6514,18 +6514,18 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "!and !or"); + assert.equal(innerHTML(div), "!and !or"); map.foo = false; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = false; - QUnit.equal(innerHTML(div), "and or"); + assert.equal(innerHTML(div), "and or"); map.foo = true; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = true; - QUnit.equal(innerHTML(div), "!and !or"); + assert.equal(innerHTML(div), "!and !or"); }); - test("#eq works with call expressions", function(){ + QUnit.test("#eq works with call expressions", function(assert) { var template = stache("{{#eq(foo, true)}}foo{{else}}bar{{/eq}}"); var map = new DefineMap({ foo: true @@ -6534,12 +6534,12 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "foo"); + assert.equal(innerHTML(div), "foo"); map.foo = false; - QUnit.equal(innerHTML(div), "bar"); + assert.equal(innerHTML(div), "bar"); }); - test("#eq works with nested call expressions", function(){ + QUnit.test("#eq works with nested call expressions", function(assert) { var template = stache("{{#and(eq(foo, true), eq(bar, true))}}and{{else}}!and{{/and}} {{#or(eq(foo, true), eq(bar, true))}}or{{else}}!or{{/or}}"); var map = new DefineMap({ @@ -6550,18 +6550,18 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "and or"); + assert.equal(innerHTML(div), "and or"); map.foo = false; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = false; - QUnit.equal(innerHTML(div), "!and !or"); + assert.equal(innerHTML(div), "!and !or"); map.foo = true; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = true; - QUnit.equal(innerHTML(div), "and or"); + assert.equal(innerHTML(div), "and or"); }); - test("#is works with call expressions", function(){ + QUnit.test("#is works with call expressions", function(assert) { var template = stache("{{#is(foo, true)}}foo{{else}}bar{{/eq}}"); var map = new DefineMap({ foo: true @@ -6570,12 +6570,12 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "foo"); + assert.equal(innerHTML(div), "foo"); map.foo = false; - QUnit.equal(innerHTML(div), "bar"); + assert.equal(innerHTML(div), "bar"); }); - test("#is works with nested call expressions", function(){ + QUnit.test("#is works with nested call expressions", function(assert) { var template = stache("{{#and(is(foo, true), is(bar, true))}}and{{else}}!and{{/and}} {{#or(is(foo, true), is(bar, true))}}or{{else}}!or{{/or}}"); var map = new DefineMap({ foo: true, @@ -6585,26 +6585,26 @@ function makeTest(name, doc, mutation) { var frag = template(map); div.appendChild(frag); - QUnit.equal(innerHTML(div), "and or"); + assert.equal(innerHTML(div), "and or"); map.foo = false; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = false; - QUnit.equal(innerHTML(div), "!and !or"); + assert.equal(innerHTML(div), "!and !or"); map.foo = true; - QUnit.equal(innerHTML(div), "!and or"); + assert.equal(innerHTML(div), "!and or"); map.bar = true; - QUnit.equal(innerHTML(div), "and or"); + assert.equal(innerHTML(div), "and or"); }); - QUnit.test("{{foo()()}} nested call expressions", function(){ + QUnit.test("{{foo()()}} nested call expressions", function(assert) { QUnit.expect(3); var div = doc.createElement('div'); var data = { foo: function(outter) { - QUnit.equal(outter, 1, 'foo should be called with 1'); + assert.equal(outter, 1, 'foo should be called with 1'); return function (inner) { - QUnit.equal(inner, 2, 'inner should be called with 2'); + assert.equal(inner, 2, 'inner should be called with 2'); return inner; }; } @@ -6614,7 +6614,7 @@ function makeTest(name, doc, mutation) { div.appendChild(frag); - QUnit.equal(innerHTML(div), 2, 'should return inner value'); + assert.equal(innerHTML(div), 2, 'should return inner value'); }); // PUT NEW TESTS RIGHT BEFORE THIS! diff --git a/test/test.js b/test/test.js index 9617b4e5..44bbf17e 100644 --- a/test/test.js +++ b/test/test.js @@ -2,7 +2,7 @@ var template = require('./template.stache!'); var nl = can.view.nodeLists.register([], undefined, true); can.stache.registerHelper('importTestHelper', function(options) { - window.parent.QUnit.equal(options.nodeList, nl.replacements[0], 'correct node list reference'); + window.parent.assert.equal(options.nodeList, nl.replacements[0], 'correct node list reference'); window.parent.removeMyself(); }); diff --git a/test/warnings-test.js b/test/warnings-test.js index 6373fd9c..9a482935 100644 --- a/test/warnings-test.js +++ b/test/warnings-test.js @@ -6,15 +6,15 @@ var Scope = require("can-view-scope"); QUnit.module("can-stache: warnings"); -testHelpers.dev.devOnlyTest("lineNumber should be set on the scope inside of a rendered string (#415)", function() { +testHelpers.dev.devOnlyTest("lineNumber should be set on the scope inside of a rendered string (#415)", function (assert) { var scope = new Scope({ foo: "classVal" }); var template = stache("
                  Hello
                  "); template(scope); - QUnit.equal(scope.get("scope.lineNumber"), 1); + assert.equal(scope.get("scope.lineNumber"), 1); }); -testHelpers.dev.devOnlyTest("should not warn for keys that exist but are `undefined` (#427)", function () { +testHelpers.dev.devOnlyTest("should not warn for keys that exist but are `undefined` (#427)", function (assert) { var VM = DefineMap.extend({ propWithoutValue: 'string' }); @@ -23,10 +23,10 @@ testHelpers.dev.devOnlyTest("should not warn for keys that exist but are `undefi stache('
                • {{propWithoutValue}}
                • ')(vm); - QUnit.equal(teardown(), 0, 'did not get warning'); + assert.equal(teardown(), 0, 'did not get warning'); }); -testHelpers.dev.devOnlyTest("should not warn for dotted keys that exist", function () { +testHelpers.dev.devOnlyTest("should not warn for dotted keys that exist", function (assert) { var ENV = DefineMap.extend({ NODE_ENV: "any" }); @@ -40,24 +40,24 @@ testHelpers.dev.devOnlyTest("should not warn for dotted keys that exist", functi var teardown = testHelpers.dev.willWarn(/Unable to find key/); stache('{{env.NODE_ENV}}')(vm); - QUnit.equal(teardown(), 0, "did not warn"); + assert.equal(teardown(), 0, "did not warn"); // Then with an env but no prop vm = new VM({env: new DefineMap()}); teardown = testHelpers.dev.willWarn(/Unable to find key/); stache('{{env.NODE_ENV}}')(vm); - QUnit.equal(teardown(), 1, "did warn"); + assert.equal(teardown(), 1, "did warn"); // Then with everything vm = new VM({env: new ENV()}); teardown = testHelpers.dev.willWarn(/Unable to find key/); stache('{{env.NODE_ENV}}')(vm); - QUnit.equal(teardown(), 0, "did not warn"); + assert.equal(teardown(), 0, "did not warn"); }); -testHelpers.dev.devOnlyTest("should not warn for scope. keys that exist", function () { +testHelpers.dev.devOnlyTest("should not warn for scope. keys that exist", function (assert) { var VM = DefineMap.extend({ name: "string", list: { @@ -72,10 +72,10 @@ testHelpers.dev.devOnlyTest("should not warn for scope. keys that exist", f var teardown = testHelpers.dev.willWarn(/Unable to find key/); stache('{{#each list}}{{scope.vm.name}}{{/each}}')(scope); - QUnit.equal(teardown(), 0, "did not warn"); + assert.equal(teardown(), 0, "did not warn"); }); -testHelpers.dev.devOnlyTest("should not warn for ../ keys that exist (#519)", function () { +testHelpers.dev.devOnlyTest("should not warn for ../ keys that exist (#519)", function (assert) { var VM = DefineMap.extend({ name: "string", list: { @@ -90,10 +90,10 @@ testHelpers.dev.devOnlyTest("should not warn for ../ keys that exist (#519) var teardown = testHelpers.dev.willWarn(/Unable to find key/); stache('{{#each list}}{{../name}}{{/each}}')(scope); - QUnit.equal(teardown(), 0, "did not warn"); + assert.equal(teardown(), 0, "did not warn"); }); -testHelpers.dev.devOnlyTest("Warnings for nested properties should not suggest using the same key (#536)", function () { +testHelpers.dev.devOnlyTest("Warnings for nested properties should not suggest using the same key (#536)", function (assert) { var Abc = DefineMap.extend({}); var VM = DefineMap.extend({ abc: { @@ -107,11 +107,11 @@ testHelpers.dev.devOnlyTest("Warnings for nested properties should not suggest u var suggestionTeardown = testHelpers.dev.willWarn(/will read from/); stache('{{abc.def}}')(scope); - QUnit.equal(warningTeardown(), 1, "gave warning"); - QUnit.equal(suggestionTeardown(), 0, "did not give suggestions"); + assert.equal(warningTeardown(), 1, "gave warning"); + assert.equal(suggestionTeardown(), 0, "did not give suggestions"); }); -testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct keys", function () { +testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct keys", function (assert) { var origGetPaths = Scope.prototype.getPathsForKey; Scope.prototype.getPathsForKey = function(key) { var paths = {}; @@ -129,9 +129,9 @@ testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct k user: {} }); - QUnit.equal(considerTeardown(), 1, 'got expected warning'); - QUnit.equal(fooOptionTeardown(), 1, 'got foo/name option'); - QUnit.equal(barOptionTeardown(), 1, 'got ../bar/name option'); + assert.equal(considerTeardown(), 1, 'got expected warning'); + assert.equal(fooOptionTeardown(), 1, 'got foo/name option'); + assert.equal(barOptionTeardown(), 1, 'got ../bar/name option'); Scope.prototype.getPathsForKey = function(key) { var paths = {}; @@ -147,13 +147,13 @@ testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct k user: {} }); - QUnit.equal(considerTeardown(), 1, 'got expected warning'); - QUnit.equal(bazOptionTeardown(), 1, 'got baz/name option'); + assert.equal(considerTeardown(), 1, 'got expected warning'); + assert.equal(bazOptionTeardown(), 1, 'got baz/name option'); Scope.prototype.getPathsForKey = origGetPaths; }); -testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct keys for nested properties (#519)", function () { +testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct keys for nested properties (#519)", function (assert) { var origGetPaths = Scope.prototype.getPathsForKey; Scope.prototype.getPathsForKey = function(key) { var paths = {}; @@ -171,15 +171,15 @@ testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct k user: {} }); - QUnit.equal(considerTeardown(), 1, 'got expected warning'); - QUnit.equal(fooOptionTeardown(), 1, 'got foo/name option'); - QUnit.equal(barOptionTeardown(), 1, 'got ../bar/name option'); + assert.equal(considerTeardown(), 1, 'got expected warning'); + assert.equal(fooOptionTeardown(), 1, 'got foo/name option'); + assert.equal(barOptionTeardown(), 1, 'got ../bar/name option'); Scope.prototype.getPathsForKey = origGetPaths; }); -testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct keys for functions (#529)", function () { +testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct keys for functions (#529)", function (assert) { var origGetPaths = Scope.prototype.getPathsForKey; Scope.prototype.getPathsForKey = function(key) { var paths = {}; @@ -199,15 +199,15 @@ testHelpers.dev.devOnlyTest("Variable not found warning should suggest correct k user: {} }); - QUnit.equal(considerTeardown(), 1, 'got expected warning'); - QUnit.equal(fooOptionTeardown(), 1, 'got foo/name option'); - QUnit.equal(barOptionTeardown(), 1, 'got ../bar/name option'); + assert.equal(considerTeardown(), 1, 'got expected warning'); + assert.equal(fooOptionTeardown(), 1, 'got foo/name option'); + assert.equal(barOptionTeardown(), 1, 'got ../bar/name option'); Scope.prototype.getPathsForKey = origGetPaths; }); -testHelpers.dev.devOnlyTest("Should warn when the closing tag of a partial does not match the opener", function () { +testHelpers.dev.devOnlyTest("Should warn when the closing tag of a partial does not match the opener", function (assert) { stache.registerPartial('partial', "
                  "); var warningTeardown = testHelpers.dev.willWarn(/bar.stache:1: unexpected closing tag {{\/partiall}} expected {{\/partial}}/); @@ -217,13 +217,13 @@ testHelpers.dev.devOnlyTest("Should warn when the closing tag of a partial does user: {} }); - QUnit.equal(warningTeardown(), 1, 'got expected warning'); + assert.equal(warningTeardown(), 1, 'got expected warning'); }); -testHelpers.dev.devOnlyTest("Should give a warning when a partial is not found #493", function () { +testHelpers.dev.devOnlyTest("Should give a warning when a partial is not found #493", function (assert) { var template, teardown = testHelpers.dev.willWarn(/Unable to find partial/); template = stache('missing.stache', "{{> aPartial}}"); template(); - QUnit.equal(teardown(), 1, "got expected warning"); + assert.equal(teardown(), 1, "got expected warning"); }); From 608a3e44a40b3af719eb2b039758a89d8a5ccab0 Mon Sep 17 00:00:00 2001 From: amechi101 Date: Thu, 16 May 2019 13:40:51 -0400 Subject: [PATCH 2/2] Fix tests for QUnit 2 --- helpers/-converter-test.js | 2 +- test/expression-test.js | 7 ++++--- test/partials-test.js | 9 ++++++--- test/stache-test.js | 29 +++++++++++++++++------------ 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/helpers/-converter-test.js b/helpers/-converter-test.js index c3881539..cbe06d55 100644 --- a/helpers/-converter-test.js +++ b/helpers/-converter-test.js @@ -69,7 +69,7 @@ QUnit.test("addConverter helpers push and pull multiple values", function(assert }); QUnit.test("Can register multiple converters at once with addConverter", function(assert) { - QUnit.expect(2); + assert.expect(2); var converters = { "converter-one": { get: function(){ diff --git a/test/expression-test.js b/test/expression-test.js index 3f006eef..e8d742bc 100644 --- a/test/expression-test.js +++ b/test/expression-test.js @@ -235,7 +235,7 @@ QUnit.test("expression.parse(str, {lookupRule: 'method', methodRule: 'call'})", }); QUnit.test("expression.parse nested Call expressions", function(assert) { - QUnit.expect(7); + assert.expect(7); assert.deepEqual(expression.parse("foo()()"), new expression.Call( @@ -249,7 +249,7 @@ QUnit.test("expression.parse nested Call expressions", function(assert) { ), "Returned the correct expression" ); - + var expr = new expression.Call( new expression.Call( new expression.Lookup('@bar'), @@ -426,7 +426,8 @@ QUnit.test("call expressions called with different scopes give different results assert.equal( res.get(), 12); }); -QUnit.test("call expressions called with different contexts (#616)", 1, function(assert) { +QUnit.test("call expressions called with different contexts (#616)", function(assert) { + assert.expect(1); var exprData = expression.parse("this.foo.doSomething()"); var doSomething = function(){ return this.value; diff --git a/test/partials-test.js b/test/partials-test.js index 35c0ffa2..f770fad3 100644 --- a/test/partials-test.js +++ b/test/partials-test.js @@ -491,7 +491,8 @@ QUnit.test("can pass values to partials as let scope", function(){ });*/ -QUnit.test("Using call expressions works and passes the nodeList", 2, function(assert) { +QUnit.test("Using call expressions works and passes the nodeList", function(assert) { + assert.expect(2); var addressView = stache("
                  {{this.street}}
                  "); var addressPartial = function(data, nodeList){ @@ -511,7 +512,8 @@ QUnit.test("Using call expressions works and passes the nodeList", 2, function(a assert.equal(frag.firstChild.firstChild.innerHTML, "Stave"); }); -QUnit.test("inline partials are accessible from call expressions", 1, function(assert) { +QUnit.test("inline partials are accessible from call expressions", function(assert) { + assert.expect(1); var view = stache( "{{{{this.street}}{{/addressPartial}}"+ @@ -527,7 +529,8 @@ QUnit.test("inline partials are accessible from call expressions", 1, function(a assert.equal(frag.firstChild.firstChild.innerHTML, "Stave"); }); -QUnit.test("recursive inline partials are accessible from call expressions", 1, function(assert) { +QUnit.test("recursive inline partials are accessible from call expressions", function(assert) { + assert.expect(1); var view = stache( "{{{{#list}}{{.}}{{/list}}

                  '); var map = new SimpleMap({ list: ['something'] @@ -3550,7 +3552,8 @@ function makeTest(name, doc, mutation) { assert.equal(frag.firstChild.className, 'red', 'else branch'); }); - QUnit.test("returns correct value for DOM attributes (#1065)", 3, function(assert) { + QUnit.test("returns correct value for DOM attributes (#1065)", function(assert) { + assert.expect(3); var template = '

                  ' + '

                  ' + '

                  '; @@ -3623,7 +3626,8 @@ function makeTest(name, doc, mutation) { }); - QUnit.test(" inside renders correctly (#1013)", 1, function(assert) { + QUnit.test("inside
                  renders correctly (#1013)", function(assert) { + assert.expect(1); var template = '
                  {{#columns}}{{/columns}}
                  '; var frag = stache(template)({ columns: new DefineList([ @@ -3934,7 +3938,8 @@ function makeTest(name, doc, mutation) { assert.equal(innerHTML(frag.firstChild), 'My Meals', 'shows if case'); }); - QUnit.test('addHelper', 3, function(assert) { + QUnit.test('addHelper', function(assert) { + assert.expect(3); var template = stache('
                  Result: {{simple first second}}
                  '); stache.addHelper('simple', function (first, second) { assert.equal(first, 2); @@ -3948,7 +3953,8 @@ function makeTest(name, doc, mutation) { assert.equal(innerHTML(frag.firstChild), 'Result: 6'); }); - QUnit.test('Helper handles list replacement (#1652)', 3, function(assert) { + QUnit.test('Helper handles list replacement (#1652)', function(assert) { + assert.expect(3); var state = new SimpleMap({ list: new DefineList([]) }); @@ -4077,7 +4083,8 @@ function makeTest(name, doc, mutation) { assert.equal(frag.firstChild.nodeValue, "http://foocdn.com/hello/world", "relative lookup works"); }); - QUnit.test('Custom attribute callbacks are called when in a conditional within a live section', 6, function(assert) { + QUnit.test('Custom attribute callbacks are called when in a conditional within a live section', function(assert) { + assert.expect(6); viewCallbacks.attr('test-attr', function(el, attrData) { assert.ok(true, "test-attr called"); assert.equal(attrData.attributeName, 'test-attr', "attributeName set correctly"); @@ -5547,7 +5554,6 @@ function makeTest(name, doc, mutation) { var map = new DefineMap({ foo: "bar" }); - var log = console.log; var done = assert.async(); console.log = function(value){ @@ -5565,7 +5571,6 @@ function makeTest(name, doc, mutation) { QUnit.test("debugger works with call expressions", function(assert) { debug.__testing.allowDebugger = false; - var log = canLog.log; var warn = canLog.warn; var logs = [ @@ -5589,7 +5594,6 @@ function makeTest(name, doc, mutation) { QUnit.test("debugger Lookup Expression calls debugger helper (#469)", function(assert) { debug.__testing.allowDebugger = false; - var log = canLog.log; var warn = canLog.warn; var logs = [ @@ -6382,7 +6386,8 @@ function makeTest(name, doc, mutation) { }); - testHelpers.dev.devOnlyTest("Arrays warn about escaping (#600)", 3, function (assert) { + testHelpers.dev.devOnlyTest("Arrays warn about escaping (#600)", function (assert) { + assert.expect(3); var map = new SimpleMap({ foo: ["

                  "] @@ -6597,7 +6602,7 @@ function makeTest(name, doc, mutation) { }); QUnit.test("{{foo()()}} nested call expressions", function(assert) { - QUnit.expect(3); + assert.expect(3); var div = doc.createElement('div'); var data = {