Skip to content

Commit

Permalink
Fix tests for QUnit 2
Browse files Browse the repository at this point in the history
  • Loading branch information
amechi101 committed May 16, 2019
1 parent 6b74387 commit 608a3e4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion helpers/-converter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
7 changes: 4 additions & 3 deletions test/expression-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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'),
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions test/partials-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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("<address>{{this.street}}</address>");

var addressPartial = function(data, nodeList){
Expand All @@ -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(
"{{<addressPartial}}<address>{{this.street}}</address>{{/addressPartial}}"+
Expand All @@ -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(
"{{<folderPartial}}"+
Expand Down
29 changes: 17 additions & 12 deletions test/stache-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ function makeTest(name, doc, mutation) {
assert.deepEqual(innerHTML(div2), "foo");
});

QUnit.test("String literals passed to helper should work (#1143)", 1, function(assert) {
QUnit.test("String literals passed to helper should work (#1143)", function(assert) {
assert.expect(1);
stache.registerHelper("concatStrings", function(arg1, arg2) {
return arg1 + arg2;
});
Expand Down Expand Up @@ -2470,7 +2471,8 @@ function makeTest(name, doc, mutation) {
assert.equal(img.getAttribute("src"), url, "images src is correct");
});

QUnit.test("empty lists update", 2, function(assert) {
QUnit.test("empty lists update", function(assert) {
assert.expect(2);
var template = stache('<p>{{#list}}{{.}}{{/list}}</p>');
var map = new SimpleMap({
list: ['something']
Expand Down Expand Up @@ -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 = '<h2 class="{{#if shown}}foo{{/if}} test1 {{#shown}}muh{{/shown}}"></h2>' +
'<h3 class="{{#if shown}}bar{{/if}} test2 {{#shown}}kuh{{/shown}}"></h3>' +
'<h4 class="{{#if shown}}baz{{/if}} test3 {{#shown}}boom{{/shown}}"></h4>';
Expand Down Expand Up @@ -3623,7 +3626,8 @@ function makeTest(name, doc, mutation) {

});

QUnit.test("<col> inside <table> renders correctly (#1013)", 1, function(assert) {
QUnit.test("<col> inside <table> renders correctly (#1013)", function(assert) {
assert.expect(1);
var template = '<table><colgroup>{{#columns}}<col class="{{class}}" />{{/columns}}</colgroup><tbody></tbody></table>';
var frag = stache(template)({
columns: new DefineList([
Expand Down Expand Up @@ -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('<div>Result: {{simple first second}}</div>');
stache.addHelper('simple', function (first, second) {
assert.equal(first, 2);
Expand All @@ -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([])
});
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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){
Expand All @@ -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 = [
Expand All @@ -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 = [
Expand Down Expand Up @@ -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: ["<p></p>"]
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 608a3e4

Please sign in to comment.