Skip to content

Commit 321a7a0

Browse files
authored
Merge pull request #41 from canjs/landscaper/qunit2
Landscaper: QUnit2 upgrade
2 parents 94425a3 + 414c7da commit 321a7a0

File tree

7 files changed

+94
-91
lines changed

7 files changed

+94
-91
lines changed

async/async-test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ QUnit.test('basics', function(assert){
2828
});
2929

3030
// Unbound and unobserved behavior
31-
QUnit.equal(canReflect.getValue(obs), 'default', 'getValue unbound');
31+
assert.equal(canReflect.getValue(obs), 'default', 'getValue unbound');
3232

3333
// Unbound , being observed behavior
3434
ObservationRecorder.start();
35-
QUnit.equal(canReflect.getValue(obs), undefined, "getValue being bound");
35+
assert.equal(canReflect.getValue(obs), undefined, "getValue being bound");
3636
var dependencies = ObservationRecorder.stop();
37-
QUnit.ok(!dependencies.valueDependencies.has(value), "did not record value");
38-
QUnit.ok(dependencies.valueDependencies.has(obs), "did record observable");
39-
QUnit.equal(dependencies.valueDependencies.size, 1, "only one value to listen to");
37+
assert.ok(!dependencies.valueDependencies.has(value), "did not record value");
38+
assert.ok(dependencies.valueDependencies.has(obs), "did record observable");
39+
assert.equal(dependencies.valueDependencies.size, 1, "only one value to listen to");
4040

4141
var changes = 0;
4242
var handler = function(newValue) {
4343
changes++;
4444
if(changes === 1) {
45-
QUnit.equal(newValue, 'a', 'onValue a');
45+
assert.equal(newValue, 'a', 'onValue a');
4646
value.set(2);
4747
} else {
48-
QUnit.equal(newValue, 'b', 'onValue b');
48+
assert.equal(newValue, 'b', 'onValue b');
4949
done();
5050
}
5151
};
@@ -54,7 +54,7 @@ QUnit.test('basics', function(assert){
5454
});
5555

5656

57-
QUnit.test("get and set Priority", function(){
57+
QUnit.test("get and set Priority", function(assert) {
5858
var value = new SimpleObservable(1);
5959

6060
var obs = new AsyncObservable(function(lastSet, resolve){
@@ -74,10 +74,10 @@ QUnit.test("get and set Priority", function(){
7474

7575
canReflect.setPriority(obs, 5);
7676

77-
QUnit.equal(canReflect.getPriority(obs), 5, "set priority");
77+
assert.equal(canReflect.getPriority(obs), 5, "set priority");
7878
});
7979

80-
QUnit.test("prevent a getter returning undefined from overwriting last resolved value", function(){
80+
QUnit.test("prevent a getter returning undefined from overwriting last resolved value", function(assert) {
8181
var value = new SimpleObservable(1);
8282

8383
var obs = new AsyncObservable(function(lastSet, resolve){
@@ -89,24 +89,24 @@ QUnit.test("prevent a getter returning undefined from overwriting last resolved
8989

9090
});
9191
obs.on(function(){});
92-
QUnit.equal( obs.get(), null );
92+
assert.equal( obs.get(), null );
9393
value.set(2);
9494

95-
QUnit.equal( obs.get(), 4 );
95+
assert.equal( obs.get(), 4 );
9696

9797
});
9898

99-
QUnit.test("prevent a getter returning undefined from overwriting last resolved value at the start", function(){
99+
QUnit.test("prevent a getter returning undefined from overwriting last resolved value at the start", function(assert) {
100100
var value = new SimpleObservable(1);
101101

102102
var obs = new AsyncObservable(function(lastSet, resolve){
103103
resolve(value.get()*2);
104104
});
105105
obs.on(function(){});
106-
QUnit.equal( obs.get(), 2 );
106+
assert.equal( obs.get(), 2 );
107107
value.set(2);
108108

109-
QUnit.equal( obs.get(), 4 );
109+
assert.equal( obs.get(), 4 );
110110

111111
});
112112

@@ -268,7 +268,7 @@ QUnit.test("resolving, then later returning should not cause duplicate events (#
268268
assert.equal(count, 2, "2 change events");
269269
});
270270

271-
QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(){
271+
QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(assert) {
272272
var value = new SimpleObservable(2);
273273

274274
var readCount = 0;
@@ -303,6 +303,6 @@ QUnit.test("proactive binding doesn't last past binding (can-stache#486)", funct
303303

304304
value.set(3);
305305

306-
QUnit.equal(readCount, 1, "internal observation only updated once");
306+
assert.equal(readCount, 1, "internal observation only updated once");
307307

308308
});

can-simple-observable-test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,52 @@ var skipProduction = steal.isEnv("production") ? QUnit.skip : QUnit.test;
1010

1111
QUnit.module('can-simple-observable');
1212

13-
QUnit.test('basics', function(){
14-
expect(5);
13+
QUnit.test('basics', function(assert) {
14+
assert.expect(5);
1515
var obs = new SimpleObservable('one');
1616

17-
QUnit.equal(canReflect.getValue(obs), 'one', 'getValue');
17+
assert.equal(canReflect.getValue(obs), 'one', 'getValue');
1818

1919
canReflect.setValue(obs, 'two');
2020
ObservationRecorder.start();
21-
QUnit.equal(canReflect.getValue(obs), 'two', 'setValue');
21+
assert.equal(canReflect.getValue(obs), 'two', 'setValue');
2222
var dependencies = ObservationRecorder.stop();
23-
QUnit.ok(dependencies.valueDependencies.has(obs), "was recorded");
23+
assert.ok(dependencies.valueDependencies.has(obs), "was recorded");
2424

2525
var handler = function(newValue) {
26-
QUnit.equal(newValue, 'three', 'onValue');
26+
assert.equal(newValue, 'three', 'onValue');
2727
};
2828
canReflect.onValue(obs, handler);
2929
canReflect.setValue(obs, 'three');
3030

3131
canReflect.offValue(obs, handler);
3232
canReflect.setValue(obs, 'four');
3333

34-
QUnit.equal(canReflect.getValue(obs), 'four', 'getValue after offValue');
34+
assert.equal(canReflect.getValue(obs), 'four', 'getValue after offValue');
3535
});
3636

37-
QUnit.test('basics with .value', function(){
38-
expect(5);
37+
QUnit.test('basics with .value', function(assert) {
38+
assert.expect(5);
3939
var obs = new SimpleObservable('one');
4040

41-
QUnit.equal(obs.value, 'one', 'getValue');
41+
assert.equal(obs.value, 'one', 'getValue');
4242

4343
obs.value = 'two';
4444
ObservationRecorder.start();
45-
QUnit.equal(obs.value, 'two', 'setValue');
45+
assert.equal(obs.value, 'two', 'setValue');
4646
var dependencies = ObservationRecorder.stop();
47-
QUnit.ok(dependencies.valueDependencies.has(obs), "was recorded");
47+
assert.ok(dependencies.valueDependencies.has(obs), "was recorded");
4848

4949
var handler = function(newValue) {
50-
QUnit.equal(newValue, 'three', 'onValue');
50+
assert.equal(newValue, 'three', 'onValue');
5151
};
5252
canReflect.onValue(obs, handler);
5353
obs.value = 'three';
5454

5555
canReflect.offValue(obs, handler);
5656
obs.value = 'four';
5757

58-
QUnit.equal(obs.value, 'four', 'getValue after offValue');
58+
assert.equal(obs.value, 'four', 'getValue after offValue');
5959
});
6060

6161
skipProduction("log observable changes", function(assert) {

key/key-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ QUnit.test("get and set Priority", function(assert) {
4747
});
4848

4949
if (supportsFunctionNames) {
50-
onlyDevTest("observable has a helpful name", function() {
50+
onlyDevTest("observable has a helpful name", function(assert) {
5151
var outer = {inner: {key: "hello"}};
5252
var observable = keyObservable(outer, "inner.key");
53-
QUnit.equal(
53+
assert.equal(
5454
canReflect.getName(observable),
5555
"keyObservable<Object{}.inner.key>",
5656
"observable has the correct name"

make-compute/make-compute-test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,26 @@ var makeCompute = require("./make-compute");
55

66
QUnit.module('can-simple-observable/make-compute');
77

8-
QUnit.test('basics', 4, function(){
8+
QUnit.test('basics', function(assert) {
9+
assert.expect(4);
910
var compute = makeCompute(new SimpleObservable(5));
10-
QUnit.equal( compute(), 5, "read");
11+
assert.equal( compute(), 5, "read");
1112
compute(6);
12-
QUnit.equal( compute(), 6, "write");
13+
assert.equal( compute(), 6, "write");
1314

1415
compute.on("change", function(ev, newVal, oldVal){
15-
QUnit.equal(newVal, 7, "bound newVal");
16-
QUnit.equal(oldVal, 6, "bound newVal");
16+
assert.equal(newVal, 7, "bound newVal");
17+
assert.equal(oldVal, 6, "bound newVal");
1718
});
1819
compute(7);
1920
});
2021

21-
QUnit.test("unbind('change')", function(){
22+
QUnit.test("unbind('change')", function(assert) {
2223
var observable = new SimpleObservable(5);
2324
var compute = makeCompute(observable);
2425
compute.on('change', function(){});
2526
compute.on('change', function(){});
26-
QUnit.equal(observable.handlers.get([]).length, 2, "2 observables");
27+
assert.equal(observable.handlers.get([]).length, 2, "2 observables");
2728
compute.unbind("change");
28-
QUnit.equal(observable.handlers.get([]).length, 0, "2 observables");
29+
assert.equal(observable.handlers.get([]).length, 0, "2 observables");
2930
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"detect-cyclic-packages": "^1.1.0",
5555
"jshint": "^2.9.1",
5656
"steal": "^2.2.1",
57-
"steal-qunit": "^1.0.1",
57+
"steal-qunit": "^2.0.0",
5858
"steal-tools": "^2.2.1",
5959
"testee": "^0.9.0"
6060
},

resolver/resolver-test.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ var ObservationRecorder = require("can-observation-recorder");
99

1010
QUnit.module('can-simple-observable/resolver');
1111

12-
QUnit.test("timer with teardown", function(){
13-
QUnit.stop();
12+
QUnit.test("timer with teardown", function(assert) {
13+
var done = assert.async();
1414

1515
var CALLS = [];
1616

@@ -29,64 +29,66 @@ QUnit.test("timer with teardown", function(){
2929
};
3030
}, {});
3131

32-
QUnit.equal( obs.get(), 0, "got initial value unbound");
33-
QUnit.deepEqual(CALLS,["GENERATOR","TEARDOWN"], "initial unbound read");
32+
assert.equal( obs.get(), 0, "got initial value unbound");
33+
assert.deepEqual(CALLS,["GENERATOR","TEARDOWN"], "initial unbound read");
3434
CALLS = [];
3535

3636
var handler = function(newVal){
37-
QUnit.equal( newVal, 1, "got first emitted value");
38-
QUnit.equal( obs.get(), 1, "got first emitted value");
39-
QUnit.deepEqual(CALLS,["INTERVAL"], "emitted value");
37+
assert.equal( newVal, 1, "got first emitted value");
38+
assert.equal( obs.get(), 1, "got first emitted value");
39+
assert.deepEqual(CALLS,["INTERVAL"], "emitted value");
4040
CALLS = [];
4141
obs.off(handler);
42-
QUnit.deepEqual(CALLS,["TEARDOWN"], "emitted value");
43-
QUnit.start();
42+
assert.deepEqual(CALLS,["TEARDOWN"], "emitted value");
43+
done();
4444
};
4545

4646
obs.on(handler);
47-
QUnit.equal( obs.get(), 0, "got initial value after bind");
48-
QUnit.deepEqual(CALLS,["GENERATOR"], "initial bind");
47+
assert.equal( obs.get(), 0, "got initial value after bind");
48+
assert.deepEqual(CALLS,["GENERATOR"], "initial bind");
4949
CALLS = [];
5050

5151
});
5252
var queues = require("can-queues");
53-
QUnit.test('basics listenTo', 14, function(assert){
53+
QUnit.test('basics listenTo', function(assert){
54+
assert.expect(14);
5455
var number = new SimpleObservable(1);
5556

5657
var map = mapEventMixin({
5758
property: 1
5859
});
5960

6061
var obs = new ResolverObservable(function testee(value){
61-
QUnit.equal( value.resolve(6), 6, "resolve returns passed value");
62+
assert.equal( value.resolve(6), 6, "resolve returns passed value");
6263

6364

6465
value.listenTo(number, function(newNumber){
6566
assert.equal(newNumber,2, "got the new number");
6667
assert.equal(this, map, "listenTo this is the context");
67-
QUnit.equal( value.resolve(5), 5, "resolve returns passed value");
68+
assert.equal( value.resolve(5), 5, "resolve returns passed value");
6869
});
6970

7071
}, map);
7172

7273
assert.equal(obs.get(), 6, "got unbound value");
7374
assert.equal(canReflect.getValue(obs), 6, "got unbound value");
7475
var listenHandlers = obs.binder[ canSymbol.for("can.meta") ].listenHandlers;
75-
QUnit.equal(listenHandlers.size(), 0, "0 handlers after read");
76+
assert.equal(listenHandlers.size(), 0, "0 handlers after read");
7677

7778
obs.on(function(newVal){
78-
QUnit.equal(newVal, 5, "got the new value");
79+
assert.equal(newVal, 5, "got the new value");
7980
});
8081
assert.equal(obs.get(), 6, "got unbound value");
8182
listenHandlers = obs.binder[ canSymbol.for("can.meta") ].listenHandlers;
82-
QUnit.equal(listenHandlers.size(), 1, "1 handlers after bind");
83+
assert.equal(listenHandlers.size(), 1, "1 handlers after bind");
8384
number.set(2);
8485

8586
assert.equal(obs.get(), 5, "got updated value");
8687
assert.equal(canReflect.getValue(obs), 5, "got updated value");
8788
});
8889

89-
QUnit.test("setter", 6, function(){
90+
QUnit.test("setter",function(assert) {
91+
assert.expect(6);
9092
var state = new SimpleObservable("IL");
9193

9294
var city = new ResolverObservable(function fullName(value){
@@ -100,27 +102,27 @@ QUnit.test("setter", 6, function(){
100102
}, mapEventMixin({}) );
101103

102104
city.set("Chicago");
103-
QUnit.equal(city.get(), "Chicago", "got unbound value");
105+
assert.equal(city.get(), "Chicago", "got unbound value");
104106

105107
city.set("Rockford");
106-
QUnit.equal(city.get(), "Rockford", "got unbound value after another set");
108+
assert.equal(city.get(), "Rockford", "got unbound value after another set");
107109

108110
var CITIES = [];
109111
city.on(function(city){
110112
CITIES.push(city);
111113
});
112114

113-
QUnit.equal(city.get(), "Rockford", "got bound value after binding");
115+
assert.equal(city.get(), "Rockford", "got bound value after binding");
114116

115117
state.set("CA");
116118

117-
QUnit.equal(city.get(), null, "updated city after state set");
119+
assert.equal(city.get(), null, "updated city after state set");
118120

119121
city.set("San Jose");
120122

121-
QUnit.equal(city.get(), "San Jose", "updated city after state set");
123+
assert.equal(city.get(), "San Jose", "updated city after state set");
122124

123-
QUnit.deepEqual(CITIES,[null,"San Jose"], "events right");
125+
assert.deepEqual(CITIES,[null,"San Jose"], "events right");
124126
});
125127

126128
QUnit.test("getValueDependencies and value dependencies", function(assert) {
@@ -222,7 +224,7 @@ QUnit.test("getWhatIChange", function(assert) {
222224
assert.ok(canReflect.getWhatIChange(dep).derive.valueDependencies.has(obs));
223225
});
224226

225-
QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(){
227+
QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(assert) {
226228
var v = new SimpleObservable(2);
227229

228230
var readCount = 0;
@@ -246,11 +248,11 @@ QUnit.test("proactive binding doesn't last past binding (can-stache#486)", funct
246248

247249
v.set(3);
248250

249-
QUnit.equal(readCount, 0, "internal observation only updated once");
251+
assert.equal(readCount, 0, "internal observation only updated once");
250252

251253
});
252254

253-
QUnit.test("reading observables does not leak the observable read", function(){
255+
QUnit.test("reading observables does not leak the observable read", function(assert) {
254256
// if an observation is listening is reading this value, the value
255257
// should not ObservationRecorder.add its deps
256258
// there is a similar test in can-define
@@ -267,13 +269,13 @@ QUnit.test("reading observables does not leak the observable read", function(){
267269

268270
var records = ObservationRecorder.stop();
269271

270-
QUnit.equal(records.keyDependencies.size, 0, "there are no key dependencies");
271-
QUnit.equal(records.valueDependencies.size, 0, "there are no valueDependencies");
272+
assert.equal(records.keyDependencies.size, 0, "there are no key dependencies");
273+
assert.equal(records.valueDependencies.size, 0, "there are no valueDependencies");
272274
});
273275

274-
QUnit.test("initial value on lastSet can be set (can-define#397)", function () {
276+
QUnit.test("initial value on lastSet can be set (can-define#397)", function(assert) {
275277
var defaulted = new ResolverObservable(function(props) {
276-
QUnit.equal(props.lastSet.get(), 5, "observable has default value");
278+
assert.equal(props.lastSet.get(), 5, "observable has default value");
277279
}, {}, 5);
278280
defaulted.get();
279281
});

0 commit comments

Comments
 (0)