Skip to content

Commit 36e4aa0

Browse files
committed
readme: Update code examples to use QUnit 2 API
1 parent f083e7d commit 36e4aa0

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

readme.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,21 @@ QUnit API and code which have to be tested are already loaded and attached to th
192192
Some tests examples
193193

194194
```javascript
195-
test("a basic test example", function () {
196-
ok(true, "this test is fine");
195+
test("a basic test example", function (assert) {
196+
assert.ok(true, "this test is fine");
197197
var value = "hello";
198-
equal("hello", value, "We expect value to be hello");
198+
assert.equal("hello", value, "We expect value to be hello");
199199
});
200200

201201
QUnit.module("Module A");
202202

203-
test("first test within module", 1, function () {
204-
ok(true, "a dummy");
203+
test("first test within module", function (assert) {
204+
assert.ok(true, "a dummy");
205205
});
206206

207-
test("second test within module", 2, function () {
208-
ok(true, "dummy 1 of 2");
209-
ok(true, "dummy 2 of 2");
207+
test("second test within module", function (assert) {
208+
assert.ok(true, "dummy 1 of 2");
209+
assert.ok(true, "dummy 2 of 2");
210210
});
211211

212212
QUnit.module("Module B", {
@@ -218,10 +218,10 @@ QUnit.module("Module B", {
218218
}
219219
});
220220

221-
test("some other test", function () {
222-
expect(2);
223-
equal(true, false, "failing test");
224-
equal(true, true, "passing test");
221+
test("some other test", function (assert) {
222+
assert.expect(2);
223+
assert.equal(true, false, "failing test");
224+
assert.equal(true, true, "passing test");
225225
});
226226

227227
QUnit.module("Module C", {
@@ -231,35 +231,34 @@ QUnit.module("Module C", {
231231
}
232232
});
233233

234-
test("this test is using shared environment", 1, function () {
235-
deepEqual({ test: 123 }, this.options, "passing test");
234+
test("this test is using shared environment", function (assert) {
235+
assert.deepEqual({ test: 123 }, this.options, "passing test");
236236
});
237237

238-
test("this is an async test example", function () {
239-
expect(2);
240-
stop();
238+
test("this is an async test example", function (assert) {
239+
var done = assert.stop();
240+
assert.expect(2);
241241
setTimeout(function () {
242-
ok(true, "finished async test");
243-
strictEqual(true, true, "Strict equal assertion uses ===");
244-
start();
242+
assert.ok(true, "finished async test");
243+
assert.strictEqual(true, true, "Strict equal assertion uses ===");
244+
done();
245245
}, 100);
246246
});
247247
```
248248

249249
### Generators support
250250

251251
```javascript
252-
test("my async test with generators", function* () {
252+
test("my async test with generators", function* (assert) {
253253
var data = yield asyncFn();
254-
equal(data, {a: 1}, 'generators work');
254+
assert.equal(data, {a: 1}, 'generators work');
255255
});
256256
```
257257

258258
### Run tests
259259

260260
```bash
261-
$ npm i
262-
$ npm test
261+
$ npm it
263262
```
264263

265264
### Coverage

0 commit comments

Comments
 (0)