Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landscaper: QUnit2 upgrade #242

Merged
merged 2 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"http-server": "^0.11.1",
"jshint": "^2.9.1",
"steal": "^2.0.0",
"steal-qunit": "^1.0.1",
"steal-qunit": "^2.0.0",
"steal-tools": "^1.1.2",
"test-saucelabs": "0.0.6",
"testee": "^0.9.0"
Expand Down
6 changes: 3 additions & 3 deletions test/link-to-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ var canRoute = require("can-route");
var QUnit = require("steal-qunit");

QUnit.module("can-route .linkTo",{
setup: function(){
beforeEach: function(assert) {
canRoute.routes = {};
}
});


QUnit.test("linkTo", function () {
QUnit.test("linkTo", function(assert) {
canRoute.routes = {};
canRoute.register("{foo}");
var res = canRoute.link("Hello", {
foo: "bar",
baz: "foo"
});
equal(res, "<a href=\"#!bar&baz=foo\">Hello</a>");
assert.equal(res, "<a href=\"#!bar&baz=foo\">Hello</a>");
});
8 changes: 4 additions & 4 deletions test/param-deparam-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ function getMsg(routes, input, method, output) {
}

QUnit.module("can-route .param and .deparam",{
setup: function(){
beforeEach: function(assert) {
canRoute.defaultBinding = "hashchange";
canRoute.routes = {};
}
});

test("param / deparam / rule", function () {
QUnit.test("param / deparam / rule", function(assert) {
var testCases = [
{
routes: [],
Expand Down Expand Up @@ -539,14 +539,14 @@ test("param / deparam / rule", function () {
var actual = canRoute[method].apply(canRoute, input);

if ("output" in assertion) {
QUnit.deepEqual(actual, assertion.output,
assert.deepEqual(actual, assertion.output,
getMsg(testCase.routes, assertion.input, " --" + assertion.method + "-->", assertion.output)
);
}

if (assertion.symmetric) {
var reverseMethod = method.indexOf("de") === 0 ? method.slice(2) : "de" + method;
QUnit.deepEqual(canRoute[reverseMethod].call(canRoute, actual), assertion.input,
assert.deepEqual(canRoute[reverseMethod].call(canRoute, actual), assertion.input,
getMsg(testCase.routes, assertion.input, " <---> ", actual)
);
}
Expand Down
50 changes: 26 additions & 24 deletions test/route-data-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ var mockRoute = require("./mock-route-binding");
require("can-observation");

QUnit.module("can-route.data", {
setup: function () {
beforeEach: function(assert) {
canRoute._teardown();
canRoute.defaultBinding = "hashchange";
this.fixture = document.getElementById("qunit-fixture");
}
});


test("can-route.data can be set to an element with a viewModel", function(){
QUnit.test("can-route.data can be set to an element with a viewModel", function(assert) {
var element = document.createElement("div");

var vm = new SimpleMap();
Expand All @@ -24,43 +24,45 @@ test("can-route.data can be set to an element with a viewModel", function(){
canRoute.data = element;


QUnit.equal(canRoute.data, vm, "works");
assert.equal(canRoute.data, vm, "works");
});


QUnit.asyncTest("Default map registers properties", function(){
mockRoute.start();
QUnit.test("Default map registers properties", function(assert) {
var ready = assert.async();
mockRoute.start();

canRoute.register("{type}/{id}");
canRoute.register("{type}/{id}");

canRoute._onStartComplete = function () {
canRoute._onStartComplete = function () {
var after = mockRoute.hash.get();
equal(after, "cat/5", "same URL");
equal(canRoute.data.type, "cat", "conflicts should be won by the URL");
equal(canRoute.data.id, "5", "conflicts should be won by the URL");
QUnit.start();
assert.equal(after, "cat/5", "same URL");
assert.equal(canRoute.data.type, "cat", "conflicts should be won by the URL");
assert.equal(canRoute.data.id, "5", "conflicts should be won by the URL");
ready();
mockRoute.stop();
};

mockRoute.hash.value = "#!cat/5";
canRoute.start();
mockRoute.hash.value = "#!cat/5";
canRoute.start();
});

QUnit.asyncTest("Property defaults influence the Type", function(){
mockRoute.start();
QUnit.test("Property defaults influence the Type", function(assert) {
var ready = assert.async();
mockRoute.start();

canRoute.register("{type}/{id}/{more}", { type: "dog", "id": 14, more: null });
canRoute.register("{type}/{id}/{more}", { type: "dog", "id": 14, more: null });

canRoute._onStartComplete = function () {
canRoute._onStartComplete = function () {
var after = mockRoute.hash.get();
equal(after, "cat/7/stuff", "same URL");
equal(canRoute.data.type, "cat", "conflicts should be won by the URL");
deepEqual(canRoute.data.id, 7, "conflicts should be won by the URL");
deepEqual(canRoute.data.more, "stuff", "null defaults are converted");
QUnit.start();
assert.equal(after, "cat/7/stuff", "same URL");
assert.equal(canRoute.data.type, "cat", "conflicts should be won by the URL");
assert.deepEqual(canRoute.data.id, 7, "conflicts should be won by the URL");
assert.deepEqual(canRoute.data.more, "stuff", "null defaults are converted");
ready();
mockRoute.stop();
};

mockRoute.hash.value = "#!cat/7/stuff";
canRoute.start();
mockRoute.hash.value = "#!cat/7/stuff";
canRoute.start();
});
30 changes: 15 additions & 15 deletions test/route-define-iframe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var QUnit = require("steal-qunit");
var canReflect = require("can-reflect");

QUnit.module("can-route with can-define/map/map in an iframe", {
setup: function () {
beforeEach: function() {
canRoute._teardown();
canRoute.urlData = canRoute.bindings.hashchange;
//canRoute.defaultBinding = "hashchange";
Expand All @@ -16,11 +16,11 @@ if (("onhashchange" in window)) {


var teardownRouteTest;
var setupRouteTest = function(callback){
var setupRouteTest = function(assert, callback){

var testarea = document.getElementById("qunit-fixture");
var iframe = document.createElement("iframe");
stop();
var done = assert.async();
window.routeTestReady = function(){
var args = canReflect.toArray(arguments);
args.unshift(iframe);
Expand All @@ -32,22 +32,22 @@ if (("onhashchange" in window)) {
setTimeout(function(){
testarea.removeChild(iframe);
setTimeout(function(){
start();
done();
},10);
},1);
};
};


if (typeof steal !== "undefined") {
test("listening to hashchange (#216, #124)", function () {
QUnit.test("listening to hashchange (#216, #124)", function(assert) {

setupRouteTest(function (iframe, iCanRoute) {
setupRouteTest(assert, function (iframe, iCanRoute) {

ok(!iCanRoute.data.bla, "Value not set yet");
assert.ok(!iCanRoute.data.bla, "Value not set yet");

iCanRoute.bind("bla", function(){
equal(iCanRoute.data.get("bla"), "blu", "Got route change event and value is as expected");
assert.equal(iCanRoute.data.get("bla"), "blu", "Got route change event and value is as expected");
teardownRouteTest();
});

Expand All @@ -59,11 +59,11 @@ if (("onhashchange" in window)) {
});
});

test("updating the hash", function () {
setupRouteTest(function (iframe, iCanRoute, loc) {
QUnit.test("updating the hash", function(assert) {
setupRouteTest(assert, function (iframe, iCanRoute, loc) {
iCanRoute._onStartComplete = function () {
var after = loc.href.substr(loc.href.indexOf("#"));
equal(after, "#!bar/" + encodeURIComponent("\/"));
assert.equal(after, "#!bar/" + encodeURIComponent("\/"));

teardownRouteTest();
};
Expand All @@ -78,8 +78,8 @@ if (("onhashchange" in window)) {
});
});

test("unsticky routes", function () {
setupRouteTest(function (iframe, iCanRoute, loc) {
QUnit.test("unsticky routes", function(assert) {
setupRouteTest(assert, function (iframe, iCanRoute, loc) {

iCanRoute.register("{type}");
iCanRoute.register("{type}/{id}");
Expand All @@ -92,7 +92,7 @@ if (("onhashchange" in window)) {

setTimeout(function () {
var after = loc.href.substr(loc.href.indexOf("#"));
equal(after, "#!bar");
assert.equal(after, "#!bar");
iCanRoute.attr({
type: "bar",
id: "\/"
Expand All @@ -105,7 +105,7 @@ if (("onhashchange" in window)) {
var isMatch = after === "#!bar/" + encodeURIComponent("\/");
var isWaitingTooLong = new Date() - time > 5000;
if (isMatch || isWaitingTooLong) {
equal(after, "#!bar/" + encodeURIComponent("\/"), "should go to type/id "+ (new Date() - time));
assert.equal(after, "#!bar/" + encodeURIComponent("\/"), "should go to type/id "+ (new Date() - time));
teardownRouteTest();
} else {
setTimeout(innerTimer, 30);
Expand Down
Loading