forked from emberjs/ember-qunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadapter-test.js
91 lines (70 loc) · 2.05 KB
/
adapter-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { module, test } from 'qunit';
import { QUnitAdapter, nonTestDoneCallback } from 'ember-qunit';
import patchAssert from './utils/patch-assert-helper';
const NATIVE_PROMISE = Promise;
import { Promise } from 'rsvp';
module('QUnitAdapter');
test('asyncStart waits for asyncEnd to finish a test', function (assert) {
const adapter = QUnitAdapter.create();
adapter.asyncStart();
setTimeout(function () {
assert.ok(true);
adapter.asyncEnd();
}, 50);
});
test('asyncStart waits for equal numbers of asyncEnd to finish a test', function (assert) {
const adapter = QUnitAdapter.create();
adapter.asyncStart();
adapter.asyncStart();
adapter.asyncEnd();
setTimeout(function () {
assert.ok(true);
adapter.asyncEnd();
}, 50);
});
test('asyncStart should handle skipped tests that has no assert', function (assert) {
let FakeQUnitWithoutAssert = {
config: {
current: {},
},
};
const adapter = QUnitAdapter.create({ qunit: FakeQUnitWithoutAssert });
adapter.asyncStart();
assert.equal(adapter.doneCallbacks.length, 1);
assert.deepEqual(adapter.doneCallbacks, [
{
test: FakeQUnitWithoutAssert.config.current,
done: nonTestDoneCallback,
},
]);
});
module('QUnitAdapter - Balanced async with native Promise', function () {
const adapter = QUnitAdapter.create();
test('asyncStart invoked', function (assert) {
adapter.asyncStart();
assert.ok(true);
patchAssert(assert);
return NATIVE_PROMISE.reject('trolol');
});
test('asyncEnd invoked', function (assert) {
assert.ok(true, 'fired!');
setTimeout(() => {
adapter.asyncEnd();
});
});
});
module('QUnitAdapter - Balanced async with RSVP.Promise', function () {
const adapter = QUnitAdapter.create();
test('asyncStart invoked', function (assert) {
adapter.asyncStart();
assert.ok(true);
patchAssert(assert);
return Promise.reject('trolol');
});
test('asyncEnd invoked', function (assert) {
assert.ok(true, 'fired!');
setTimeout(() => {
adapter.asyncEnd();
});
});
});