Skip to content

Commit 9e9a27b

Browse files
author
vstefanovic97
committed
Fix @typs/qunit overrides for latest qunit version
1 parent 0fd92b5 commit 9e9a27b

File tree

7 files changed

+99
-38
lines changed

7 files changed

+99
-38
lines changed

addon/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@release-it-plugins/lerna-changelog": "^6.0.0",
5656
"@rollup/plugin-babel": "^5.3.0",
5757
"@tsconfig/ember": "^2.0.0",
58-
"@types/qunit": "^2.19.6",
58+
"@types/qunit": "^2.19.12",
5959
"@types/rsvp": "^4.0.4",
6060
"concurrently": "^8.0.1",
6161
"ember-source": "^5.0.0",

addon/types/index.d.ts

+42-24
Original file line numberDiff line numberDiff line change
@@ -179,30 +179,6 @@ declare global {
179179
}
180180

181181
interface QUnit {
182-
/**
183-
* Add a test to run.
184-
*
185-
* Add a test to run using `QUnit.test()`.
186-
*
187-
* The `assert` argument to the callback contains all of QUnit's assertion
188-
* methods. Use this argument to call your test assertions.
189-
*
190-
* `QUnit.test()` can automatically handle the asynchronous resolution of a
191-
* Promise on your behalf if you return a thenable Promise as the result of
192-
* your callback function.
193-
*
194-
* @param name Title of unit being tested
195-
* @param callback Function to close over assertions
196-
*/
197-
// SAFETY: this is just wildly, impossibly unsafe. QUnit cannot -- ever! --
198-
// provide this guarantee. However, it's also the only way to support TS
199-
// in tests in Ember until we move the community over entirely to using
200-
// `<template>` and local scope.
201-
test<TC extends TestContext>(
202-
name: string,
203-
callback: (this: TC, assert: Assert) => void | Promise<unknown>
204-
): void;
205-
206182
/**
207183
* Adds a test to exclusively run, preventing all other tests from running.
208184
*
@@ -269,4 +245,46 @@ declare global {
269245
callback?: (this: TC, assert: Assert) => void | Promise<unknown>
270246
): void;
271247
}
248+
249+
namespace QUnit {
250+
interface TestFunction {
251+
// SAFETY: this is just wildly, impossibly unsafe. QUnit cannot -- ever! --
252+
// provide this guarantee. However, it's also the only way to support TS
253+
// in tests in Ember until we move the community over entirely to using
254+
// `<template>` and local scope.
255+
<TC extends TestContext>(
256+
name: string,
257+
callback: (this: TC, assert: Assert) => void | Promise<unknown>
258+
): void;
259+
}
260+
261+
interface SkipFunction {
262+
<TC extends TestContext>(
263+
name: string,
264+
callback?: (this: TC, assert: Assert) => void | Promise<unknown>
265+
): void;
266+
}
267+
268+
interface TodoFunction {
269+
<TC extends TestContext>(
270+
name: string,
271+
callback?: (this: TC, assert: Assert) => void | Promise<unknown>
272+
): void;
273+
}
274+
275+
interface OnlyFunction {
276+
<TC extends TestContext>(
277+
name: string,
278+
callback: (this: TC, assert: Assert) => void | Promise<unknown>
279+
): void;
280+
}
281+
282+
interface EachFunction {
283+
<TC extends TestContext, T>(
284+
name: string,
285+
dataset: T[],
286+
callback: (this: TC, assert: Assert, data: T) => void | Promise<unknown>
287+
): void;
288+
}
289+
}
272290
}

pnpm-lock.yaml

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@glimmer/component": "^1.1.2",
4242
"@glimmer/tracking": "^1.1.2",
4343
"@tsconfig/ember": "^2.0.0",
44-
"@types/qunit": "^2.19.6",
44+
"@types/qunit": "^2.19.12",
4545
"@types/rsvp": "^4.0.4",
4646
"concurrently": "^8.0.1",
4747
"ember-angle-bracket-invocation-polyfill": "^3.0.2",

test-buildtime-options-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@glimmer/component": "^1.1.2",
4242
"@glimmer/tracking": "^1.1.2",
4343
"@tsconfig/ember": "^2.0.0",
44-
"@types/qunit": "^2.19.6",
44+
"@types/qunit": "^2.19.12",
4545
"@types/rsvp": "^4.0.4",
4646
"concurrently": "^8.0.1",
4747
"ember-angle-bracket-invocation-polyfill": "^3.0.2",

test-types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@ember/test-helpers": "^3.0.3",
1515
"@glimmer/component": "^1.1.2",
1616
"@tsconfig/ember": "^2.0.0",
17-
"@types/qunit": "^2.19.6",
17+
"@types/qunit": "^2.19.12",
1818
"ember-cli-htmlbars": "^6.3.0",
1919
"ember-resolver": "^10.1.0",
2020
"ember-source": "^5.0.0",

test-types/src/tests.ts

+42
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,45 @@ module('with setup options', function (hooks) {
337337
setupRenderingTest(hooks, { resolver });
338338
setupApplicationTest(hooks, { resolver });
339339
});
340+
341+
module('methods on test function', function () {
342+
test.each('example with each', [1,2,3], async function (assert, number) {
343+
// setup the outer context
344+
this.set('value', 'cat');
345+
346+
await render(hbs`{{number}}`);
347+
348+
assert.strictEqual(number, 1)
349+
});
350+
351+
test.skip('example with skip', async function (assert) {
352+
// setup the outer context
353+
this.set('value', 'cat');
354+
355+
await render(hbs`{{number}}`);
356+
357+
assert.ok(this.get('value'));
358+
});
359+
360+
test.skip('example with skip w/o callback');
361+
362+
test.todo('example with todo', async function (assert) {
363+
// setup the outer context
364+
this.set('value', 'cat');
365+
366+
await render(hbs`{{number}}`);
367+
368+
assert.ok(this.get('value'));
369+
});
370+
371+
test.todo('example with todo w/o callback');
372+
373+
test.only('example with only', async function (assert) {
374+
// setup the outer context
375+
this.set('value', 'cat');
376+
377+
await render(hbs`{{number}}`);
378+
379+
assert.ok(this.get('value'));
380+
});
381+
})

0 commit comments

Comments
 (0)