Skip to content

Commit

Permalink
Merge pull request #22 from canjs/landscaper/qunit2
Browse files Browse the repository at this point in the history
Landscaper: QUnit2 upgrade
  • Loading branch information
cherifGsoul authored May 26, 2019
2 parents 41eb438 + d3228e3 commit 963384a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions can-stache-route-helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ var helpers = require("./can-stache-route-helpers");

QUnit.module("can-stache-route-helpers");

QUnit.test("exports helper object", function() {
QUnit.equal(typeof helpers.routeUrl, "function", "routeUrl exists");
QUnit.equal(typeof helpers.routeCurrent, "function", "routeCurrent exists");
QUnit.test("exports helper object", function(assert) {
assert.equal(typeof helpers.routeUrl, "function", "routeUrl exists");
assert.equal(typeof helpers.routeCurrent, "function", "routeCurrent exists");
});

QUnit.test("routeUrl and routeCurrent", function(){
stop();
QUnit.test("routeUrl and routeCurrent", function(assert) {
var done = assert.async();
mockRoute.start();
var routeData = new CanMap({});
route.data = routeData;
Expand All @@ -25,25 +25,25 @@ QUnit.test("routeUrl and routeCurrent", function(){
recipe: new CanMap({id: 5, name: 'Cool recipe'})
});

QUnit.equal( frag.firstChild.getAttribute("href"), "#!&page=recipe&id=5", "href set");
assert.equal( frag.firstChild.getAttribute("href"), "#!&page=recipe&id=5", "href set");

template = stache("<a href=\"{{routeUrl(page='recipe' id=recipe.id}}\">{{recipe.name}}</a>");

frag = template({
recipe: new CanMap({id: 5, name: 'Cool recipe'})
});

QUnit.equal( frag.firstChild.getAttribute("href"), "#!&page=recipe&id=5", "href set");
assert.equal( frag.firstChild.getAttribute("href"), "#!&page=recipe&id=5", "href set");

template = stache("{{#routeCurrent(undefined)}}yes{{else}}no{{/routeCurrent}}");

frag = template({});
QUnit.equal(frag.firstChild.nodeValue, "yes", "route is current");
assert.equal(frag.firstChild.nodeValue, "yes", "route is current");

template = stache("{{#routeCurrent()}}yes{{else}}no{{/routeCurrent}}");

frag = template({});
QUnit.equal(frag.firstChild.nodeValue, "yes", "route is current");
assert.equal(frag.firstChild.nodeValue, "yes", "route is current");

route.attr({"foo":"bar", page: 'recipes'});

Expand All @@ -52,28 +52,28 @@ QUnit.test("routeUrl and routeCurrent", function(){
template = stache("{{#routeCurrent()}}yes{{else}}no{{/routeCurrent}}");

frag = template({});
QUnit.equal(frag.firstChild.nodeValue, "no", "route is not current");
assert.equal(frag.firstChild.nodeValue, "no", "route is not current");

template = stache("{{#routeCurrent(foo='bar', true)}}yes{{else}}no{{/routeCurrent}}");
frag = template({});
QUnit.equal(frag.firstChild.nodeValue, "yes", "route is somewhat current");
assert.equal(frag.firstChild.nodeValue, "yes", "route is somewhat current");

template = stache("{{#routeCurrent(foo='bar', true)}}yes{{else}}no{{/routeCurrent}}");
frag = template({});
QUnit.equal(frag.firstChild.nodeValue, "yes", "route is somewhat current");
assert.equal(frag.firstChild.nodeValue, "yes", "route is somewhat current");

template = stache("<a href=\"{{routeUrl(page='recipes' id=6, true)}}\"></a>");
frag = template({});

QUnit.equal( frag.firstChild.getAttribute("href"), "#!&foo=bar&page=recipes&id=6", "merge works helper");
assert.equal( frag.firstChild.getAttribute("href"), "#!&foo=bar&page=recipes&id=6", "merge works helper");

template = stache("<a href=\"{{routeUrl(page='recipe' id=5,true)}}\"></a>");
frag = template({});

QUnit.equal( frag.firstChild.getAttribute("href"), "#!&foo=bar&page=recipe&id=5", "merge works call expression");
assert.equal( frag.firstChild.getAttribute("href"), "#!&foo=bar&page=recipe&id=5", "merge works call expression");

mockRoute.stop();
start();
done();
},100);

});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"can-route-mock": "^1.0.0",
"jshint": "^2.9.1",
"steal": "^2.0.0",
"steal-qunit": "^1.0.1",
"steal-qunit": "^2.0.0",
"steal-tools": "^2.0.2",
"testee": "^0.9.0"
},
Expand Down

0 comments on commit 963384a

Please sign in to comment.