Skip to content

Commit ce66189

Browse files
yomexzoKrinkle
authored andcommitted
tests: rewrite to use assert context instead of deprecated globals
Ref #132
1 parent 197cc75 commit ce66189

7 files changed

Lines changed: 46 additions & 46 deletions

File tree

test/fixtures/async-test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
test('1', 1, function (){
2-
ok(true, "tests intermixing sync and async tests #1");
1+
test('1', 1, function (assert){
2+
assert.ok(true, "tests intermixing sync and async tests #1");
33
});
44

5-
test('a', 2, function(){
6-
stop();
5+
test('a', 2, function(assert){
6+
var done = assert.async();
77

88
setTimeout(function() {
9-
ok(true, 'test a1');
10-
ok(true, 'test a2');
11-
start();
9+
assert.ok(true, 'test a1');
10+
assert.ok(true, 'test a2');
11+
done();
1212
}, 10000);
1313
});
1414

1515
test('2', 1, function (){
16-
ok(true, "tests intermixing sync and async tests #2");
16+
assert.ok(true, "tests intermixing sync and async tests #2");
1717
});
1818

19-
test('b', 2, function(){
20-
stop();
19+
test('b', 2, function(assert){
20+
var done = assert.async();
2121

2222
setTimeout(function() {
23-
ok(true, 'test b1');
24-
ok(true, 'test b2');
25-
start();
23+
assert.ok(true, 'test b1');
24+
assert.ok(true, 'test b2');
25+
done();
2626
}, 10);
2727
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
test("Dependency file required as global", function() {
2-
equal(typeof whereFrom, "function");
3-
equal(whereFrom(), "I was required as global");
1+
test("Dependency file required as global", function(assert) {
2+
assert.equal(typeof whereFrom, "function");
3+
assert.equal(whereFrom(), "I was required as global");
44
});
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
test("Dependency file required as a namespace object", function() {
2-
strictEqual(typeof testns != "undefined", true);
3-
equal(typeof testns.whereFrom, "function", "right method attached to right object");
4-
equal(testns.whereFrom(), "I was required as a namespace object");
1+
test("Dependency file required as a namespace object", function(assert) {
2+
assert.strictEqual(typeof testns != "undefined", true);
3+
assert.equal(typeof testns.whereFrom, "function", "right method attached to right object");
4+
assert.equal(testns.whereFrom(), "I was required as a namespace object");
55
});

test/fixtures/coverage-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
test('myMethod test', function() {
2-
equal(myMethod(), 123, 'myMethod returns right result');
1+
test('myMethod test', function(assert) {
2+
assert.equal(myMethod(), 123, 'myMethod returns right result');
33
});
44

5-
test('myAsyncMethod test', function() {
6-
ok(true, 'myAsyncMethod started');
5+
test('myAsyncMethod test', function(assert) {
6+
assert.ok(true, 'myAsyncMethod started');
77

8-
stop();
9-
expect(2);
8+
var done = assert.async();
9+
assert.expect(2);
1010

1111
myAsyncMethod(function(data) {
12-
equal(data, 123, 'myAsyncMethod returns right result');
13-
start();
12+
assert.equal(data, 123, 'myAsyncMethod returns right result');
13+
done();
1414
});
1515
});

test/fixtures/generators-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
test('generators', function* () {
1+
test('generators', function* (assert) {
22
var data = yield thunk();
3-
deepEqual(data, {a: 1}, 'woks');
3+
assert.deepEqual(data, {a: 1}, 'woks');
44
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
test('infinite loop', function() {
2-
ok(true)
1+
test('infinite loop', function(assert) {
2+
assert.ok(true)
33
})

test/fixtures/testrunner-tests.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
test('myMethod test', function() {
2-
equal(myMethod(), 123, 'myMethod returns right result');
3-
equal(myMethod(), 321, 'this should trigger an error');
1+
test('myMethod test', function(assert) {
2+
assert.equal(myMethod(), 123, 'myMethod returns right result');
3+
assert.equal(myMethod(), 321, 'this should trigger an error');
44
});
55

6-
test('myAsyncMethod test', function() {
7-
ok(true, 'myAsyncMethod started');
6+
test('myAsyncMethod test', function(assert) {
7+
var done = assert.async();
8+
assert.expect(3);
89

9-
stop();
10-
expect(3);
10+
assert.ok(true, 'myAsyncMethod started');
1111

1212
myAsyncMethod(function(data) {
13-
equal(data, 123, 'myAsyncMethod returns right result');
14-
equal(data, 321, 'this should trigger an error');
15-
start();
13+
assert.equal(data, 123, 'myAsyncMethod returns right result');
14+
assert.equal(data, 321, 'this should trigger an error');
15+
done();
1616
});
1717
});
1818

19-
test('circular reference', function() {
20-
equal(global, global, 'test global');
19+
test('circular reference', function(assert) {
20+
assert.equal(global, global, 'test global');
2121
});
2222

23-
test('use original Date', function() {
23+
test('use original Date', function(assert) {
2424
var timekeeper = require('timekeeper');
2525

2626
timekeeper.travel(Date.now() - 1000000);
2727

28-
ok(true, 'date modified');
28+
assert.ok(true, 'date modified');
2929
});

0 commit comments

Comments
 (0)