From c134c1e6bd9e6dbc5f23067049cadc3ce0302bba Mon Sep 17 00:00:00 2001 From: Cherif BOUCHELAGHEM Date: Fri, 10 May 2019 19:01:34 +0100 Subject: [PATCH 1/2] Landscaper: QUnit2 upgrade --- can-globals-test.js | 120 ++++++++++---------- global/global-test.js | 14 +-- is-browser-window/is-browser-window-test.js | 4 +- is-web-worker/is-web-worker-test.js | 4 +- package.json | 2 +- test-wrapper.js | 6 +- 6 files changed, 75 insertions(+), 75 deletions(-) diff --git a/can-globals-test.js b/can-globals-test.js index c77444e..586632a 100644 --- a/can-globals-test.js +++ b/can-globals-test.js @@ -22,93 +22,93 @@ function loop(fn, count, ctx){ QUnit.module('can-globals/can-globals-proto'); -QUnit.test('getKeyValue of undefined property', function() { +QUnit.test('getKeyValue of undefined property', function(assert) { globals = new Globals(); globals.getKeyValue('test'); - ok(true); + assert.ok(true); }); -QUnit.test('setKeyValue of undefined property', function() { +QUnit.test('setKeyValue of undefined property', function(assert) { globals = new Globals(); globals.setKeyValue('foo', 'bar'); - equal(globals.getKeyValue('foo'), 'bar'); + assert.equal(globals.getKeyValue('foo'), 'bar'); }); -QUnit.test('deleteKeyValue of undefined property', function() { +QUnit.test('deleteKeyValue of undefined property', function(assert) { globals = new Globals(); globals.deleteKeyValue('test'); - ok(true); + assert.ok(true); }); -QUnit.test('onKeyValue of undefined property', function() { +QUnit.test('onKeyValue of undefined property', function(assert) { globals = new Globals(); globals.onKeyValue('test', function() {}); - ok(true); + assert.ok(true); globals.offKeyValue('test'); }); -QUnit.test('offKeyValue of undefined property', function() { +QUnit.test('offKeyValue of undefined property', function(assert) { globals = new Globals(); globals.offKeyValue('test', function() {}); - ok(true); + assert.ok(true); }); -QUnit.test('makeExport of undefined property', function() { +QUnit.test('makeExport of undefined property', function(assert) { globals = new Globals(); globals.makeExport('test'); - ok(true); + assert.ok(true); }); -QUnit.test('define with cache disabled', function() { +QUnit.test('define with cache disabled', function(assert) { var getter = spy('bar'); globals = new Globals(); globals.define('foo', getter, false); loop(function(){ globals.getKeyValue('foo'); }, 5); - equal(getter.callCount, 5); + assert.equal(getter.callCount, 5); }); -QUnit.test('define with cache enabled', function() { +QUnit.test('define with cache enabled', function(assert) { var getter = spy('bar'); globals = new Globals(); globals.define('foo', getter); loop(function(){ globals.getKeyValue('foo'); }, 5); - equal(getter.callCount, 1); + assert.equal(getter.callCount, 1); }); -QUnit.test('define and get a new property', function() { +QUnit.test('define and get a new property', function(assert) { globals = new Globals(); globals.define('test', 'default'); - equal(globals.getKeyValue('test'), 'default'); + assert.equal(globals.getKeyValue('test'), 'default'); }); -QUnit.test('setKeyValue of existing property to string', function() { +QUnit.test('setKeyValue of existing property to string', function(assert) { globals = new Globals(); globals.define('test', 'default'); globals.setKeyValue('test', 'updated'); - equal(globals.getKeyValue('test'), 'updated'); + assert.equal(globals.getKeyValue('test'), 'updated'); }); -QUnit.test('setKeyValue of existing property to undefined', function() { +QUnit.test('setKeyValue of existing property to undefined', function(assert) { globals = new Globals(); globals.define('test', 'default'); globals.setKeyValue('test', undefined); - equal(globals.getKeyValue('test'), undefined); + assert.equal(globals.getKeyValue('test'), undefined); }); -QUnit.test('setKeyValue of existing property to a function', function() { +QUnit.test('setKeyValue of existing property to a function', function(assert) { globals = new Globals(); globals.define('test', 'default'); globals.setKeyValue('test', function(){ return 'foo'; }); - equal(globals.getKeyValue('test'), 'foo'); + assert.equal(globals.getKeyValue('test'), 'foo'); }); -QUnit.test('setKeyValue on an existing property should reset cache', function(){ +QUnit.test('setKeyValue on an existing property should reset cache', function(assert) { var globals = new Globals(); var bar = function() { return 'bar'; @@ -118,18 +118,18 @@ QUnit.test('setKeyValue on an existing property should reset cache', function(){ globals.setKeyValue('foo', function(){ return 'baz'; }); - equal(globals.getKeyValue('foo'), 'baz'); + assert.equal(globals.getKeyValue('foo'), 'baz'); }); -QUnit.test('deleteKeyValue to reset property to default', function() { +QUnit.test('deleteKeyValue to reset property to default', function(assert) { var globals = new Globals(); globals.define('test', 'default'); globals.setKeyValue('test', 'updated'); globals.deleteKeyValue('test'); - equal(globals.getKeyValue('test'), 'default'); + assert.equal(globals.getKeyValue('test'), 'default'); }); -QUnit.test('deleteKeyValue should clear cache', function() { +QUnit.test('deleteKeyValue should clear cache', function(assert) { var globals = new Globals(); var bar = spy('bar'); globals.define('foo', bar); @@ -139,10 +139,10 @@ QUnit.test('deleteKeyValue should clear cache', function() { }); globals.deleteKeyValue('foo'); globals.getKeyValue('foo'); - equal(bar.callCount, 2); + assert.equal(bar.callCount, 2); }); -QUnit.test('listen for key change', function() { +QUnit.test('listen for key change', function(assert) { var globals = new Globals(); var handler = spy(); globals.define('test', 'default'); @@ -151,47 +151,47 @@ QUnit.test('listen for key change', function() { globals.setKeyValue('test', 'updated'); globals.setKeyValue('foo', 'baz'); globals.deleteKeyValue('test'); - equal(handler.callCount, 2); - deepEqual(mapEvents(handler), [ + assert.equal(handler.callCount, 2); + assert.deepEqual(mapEvents(handler), [ 'updated', 'default' ]); globals.offKeyValue('test'); }); -QUnit.test('remove event listener for key', function() { +QUnit.test('remove event listener for key', function(assert) { var globals = new Globals(); var handler = spy(); globals.define('test', 'foo'); globals.onKeyValue('test', handler); globals.offKeyValue('test', handler); globals.setKeyValue('test', 'updated'); - equal(handler.callCount, 0); + assert.equal(handler.callCount, 0); }); -QUnit.test('makeExport of key', function() { +QUnit.test('makeExport of key', function(assert) { var globals = new Globals(); globals.define('foo', 'bar'); var e = globals.makeExport('foo'); - equal(e(), 'bar'); + assert.equal(e(), 'bar'); e('baz'); - equal(e(), 'baz'); + assert.equal(e(), 'baz'); e(undefined); - equal(e(), 'bar'); + assert.equal(e(), 'bar'); }); -QUnit.test('reset export value with null (can-stache#288)', function() { +QUnit.test('reset export value with null (can-stache#288)', function(assert) { var globals = new Globals(); globals.define('foo', 'bar'); var e = globals.makeExport('foo'); - equal(e(), 'bar'); + assert.equal(e(), 'bar'); e('baz'); - equal(e(), 'baz'); + assert.equal(e(), 'baz'); e(null); - equal(e(), 'bar'); + assert.equal(e(), 'bar'); }); -QUnit.test('reset cleares cache on all keys', function(){ +QUnit.test('reset cleares cache on all keys', function(assert) { var globals = new Globals(); var bar = spy('bar'); var qux = spy('qux'); @@ -206,22 +206,22 @@ QUnit.test('reset cleares cache on all keys', function(){ globals.getKeyValue('foo'); globals.getKeyValue('baz'); }, 5); - equal(bar.callCount, 2); - equal(qux.callCount, 2); + assert.equal(bar.callCount, 2); + assert.equal(qux.callCount, 2); }); -QUnit.test('reset should reset all keys to default value (#31)', function(){ +QUnit.test('reset should reset all keys to default value (#31)', function(assert) { var globals = new Globals(); globals.define('foo', 'bar'); globals.define('baz', 'qux'); globals.setKeyValue('foo', 'red'); globals.setKeyValue('baz', 'green'); globals.reset(); - equal(globals.getKeyValue('foo'), 'bar'); - equal(globals.getKeyValue('baz'), 'qux'); + assert.equal(globals.getKeyValue('foo'), 'bar'); + assert.equal(globals.getKeyValue('baz'), 'qux'); }); -QUnit.test('reset triggers events', function(){ +QUnit.test('reset triggers events', function(assert) { var globals = new Globals(); var fooHandler = spy(); var barHandler = spy(); @@ -232,13 +232,13 @@ QUnit.test('reset triggers events', function(){ globals.onKeyValue('foo', fooHandler); globals.onKeyValue('bar', barHandler); globals.reset(); - equal(fooHandler.callCount, 1); - equal(barHandler.callCount, 1); + assert.equal(fooHandler.callCount, 1); + assert.equal(barHandler.callCount, 1); globals.offKeyValue('foo'); globals.offKeyValue('bar'); }); -QUnit.test('export helper value can be set to a function', function(){ +QUnit.test('export helper value can be set to a function', function(assert) { var globals = new Globals(); var foo = spy(); globals.setKeyValue('foo', function(){ @@ -246,19 +246,19 @@ QUnit.test('export helper value can be set to a function', function(){ }); var fooExport = globals.makeExport('foo'); fooExport(foo); - QUnit.equal(typeof fooExport(), 'function'); - QUnit.equal(foo.callCount, 0); + assert.equal(typeof fooExport(), 'function'); + assert.equal(foo.callCount, 0); fooExport()(); - QUnit.equal(foo.callCount, 1); + assert.equal(foo.callCount, 1); }); -QUnit.test('onKeyValue should dispatch the resolved value (#29)', function(){ +QUnit.test('onKeyValue should dispatch the resolved value (#29)', function(assert) { var globals = new Globals(); var foo = 'foo'; globals.define('foo', ''); globals.onKeyValue('foo', function(value){ - QUnit.equal(value, foo); + assert.equal(value, foo); }); globals.setKeyValue('foo', function(){ return foo; @@ -266,12 +266,12 @@ QUnit.test('onKeyValue should dispatch the resolved value (#29)', function(){ globals.offKeyValue('foo'); }); -QUnit.test('onKeyValue should not trigger multiple calls of the value function (#33)', function(){ +QUnit.test('onKeyValue should not trigger multiple calls of the value function (#33)', function(assert) { var globals = new Globals(); var baz = spy('baz'); globals.define('foo', 'bar'); globals.onKeyValue('foo', function(){}); globals.setKeyValue('foo', baz); globals.getKeyValue('foo'); - equal(baz.callCount, 1); + assert.equal(baz.callCount, 1); }); diff --git a/global/global-test.js b/global/global-test.js index 53c4e8e..30277f1 100644 --- a/global/global-test.js +++ b/global/global-test.js @@ -9,26 +9,26 @@ function isBrowserWindow(){ QUnit.module('can-globals/global/global'); -test('basics', function(){ +QUnit.test('basics', function(assert) { if(isBrowserWindow()) { - ok(getGlobal() === window); + assert.ok(getGlobal() === window); } else { - ok(getGlobal() === global); + assert.ok(getGlobal() === global); } }); if(!isBrowserWindow()) { QUnit.module('in Node with fake window', { - setup: function(){ + beforeEach: function(assert) { this.oldWindow = global.window; global.window = {}; }, - teardown: function(){ + afterEach: function(assert) { global.window = this.oldWindow; } }); - test('Gets the Node global', function(){ - ok(getGlobal() === global); + QUnit.test('Gets the Node global', function(assert) { + assert.ok(getGlobal() === global); }); } diff --git a/is-browser-window/is-browser-window-test.js b/is-browser-window/is-browser-window-test.js index feb6f62..0673dd1 100644 --- a/is-browser-window/is-browser-window-test.js +++ b/is-browser-window/is-browser-window-test.js @@ -5,6 +5,6 @@ var isBrowserWindow = require('./is-browser-window'); QUnit.module("can-globals/is-browser-window/is-browser-window"); -QUnit.test("basics", function(){ - equal(typeof isBrowserWindow(), "boolean"); +QUnit.test("basics", function(assert) { + assert.equal(typeof isBrowserWindow(), "boolean"); }); diff --git a/is-web-worker/is-web-worker-test.js b/is-web-worker/is-web-worker-test.js index 4e8df7b..3025b7b 100644 --- a/is-web-worker/is-web-worker-test.js +++ b/is-web-worker/is-web-worker-test.js @@ -5,6 +5,6 @@ var isWebWorker = require('./is-web-worker'); QUnit.module("can-globals/is-web-worker/is-web-worker"); -QUnit.test("basics", function(){ - equal(typeof isWebWorker(), "boolean"); +QUnit.test("basics", function(assert) { + assert.equal(typeof isWebWorker(), "boolean"); }); diff --git a/package.json b/package.json index c8d2cb3..136779d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "jshint": "^2.9.5", "qunitjs": "^2.4.0", "steal": "^2.2.1", - "steal-qunit": "^1.0.1", + "steal-qunit": "^2.0.0", "steal-tools": "^2.2.1", "testee": "^0.9.0" } diff --git a/test-wrapper.js b/test-wrapper.js index 59a732f..db241a0 100644 --- a/test-wrapper.js +++ b/test-wrapper.js @@ -6,12 +6,12 @@ var isQunit = testType === 'qunit'; if (isMochaQUnitUI) { // mocha-qunit-ui does not support async QUnit.assert.async = function () { - QUnit.stop(); + var done = assert.async(); return function done (error) { if (error) { - return QUnit.ok(false, '' + error); + return assert.ok(false, '' + error); } - QUnit.start(); + done(); }; }; From 33cd0cbfcc126c5ccc5cd265d2aa58e6dfa230d0 Mon Sep 17 00:00:00 2001 From: Cherif BOUCHELAGHEM Date: Tue, 14 May 2019 23:58:47 +0100 Subject: [PATCH 2/2] Fix tests for QUnit 2 --- package.json | 1 - test-wrapper.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 136779d..f5f87bd 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "devDependencies": { "detect-cyclic-packages": "^1.1.0", "jshint": "^2.9.5", - "qunitjs": "^2.4.0", "steal": "^2.2.1", "steal-qunit": "^2.0.0", "steal-tools": "^2.2.1", diff --git a/test-wrapper.js b/test-wrapper.js index db241a0..6b66f24 100644 --- a/test-wrapper.js +++ b/test-wrapper.js @@ -18,7 +18,7 @@ if (isMochaQUnitUI) { QUnit.test = test; module.exports = QUnit; } else if (isQunit) { - module.exports = require('qunitjs'); + module.exports = require('qunit'); } else { module.exports = require('steal-qunit'); }