Skip to content

Commit 2128af4

Browse files
committed
Update TS tests
1 parent 5f4bdf0 commit 2128af4

2 files changed

Lines changed: 37 additions & 38 deletions

File tree

files/tests/test-helper.__ext__

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import * as QUnit from 'qunit';
44
import { setApplication } from '@ember/test-helpers';
55
import { setup } from 'qunit-dom';
66
import { start as qunitStart, setupEmberOnerrorValidation } from 'ember-qunit';
7-
import { getGlobalConfig } from '@embroider/macros/src/addon/runtime';
7+
<% if (typescript) { %>// @ts-expect-error @embroider/macros does not provide types
8+
<% } %>import { getGlobalConfig } from '@embroider/macros/src/addon/runtime';
89

910
class Router extends EmberRouter {
1011
location = 'none';
@@ -22,10 +23,13 @@ class TestApp extends EmberApp {
2223
Router.map(function () {});
2324

2425
export function start() {
25-
const theMacrosGlobal = getGlobalConfig();
26+
<% if (typescript) { %>// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
27+
<% } %>const theMacrosGlobal = getGlobalConfig();
2628

27-
theMacrosGlobal['@embroider/macros'] ||= {};
28-
theMacrosGlobal['@embroider/macros'].isTesting ||= true;
29+
<% if (typescript) { %>// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
30+
<% } %>theMacrosGlobal['@embroider/macros'] ||= {};
31+
<% if (typescript) { %>// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
32+
<% } %>theMacrosGlobal['@embroider/macros'].isTesting ||= true;
2933

3034
setApplication(
3135
TestApp.create({

tests/smoke-tests/--typescript.test.ts

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ import fixturify from 'fixturify';
55
import { execa } from 'execa';
66
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
77

8-
import {
9-
assertGeneratedCorrectly,
10-
dirContents,
11-
filesMatching,
12-
SUPPORTED_PACKAGE_MANAGERS,
13-
} from '../helpers.js';
8+
import { assertGeneratedCorrectly, filesMatching, SUPPORTED_PACKAGE_MANAGERS } from '../helpers.js';
149
const blueprintPath = path.join(__dirname, '../..');
1510
let localEmberCli = require.resolve('ember-cli/bin/ember');
1611

@@ -92,56 +87,56 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
9287
await commandSucceeds(`${packageManager} run build`);
9388

9489
expect(
95-
await filesMatching('src/**', addonDir),
90+
(await filesMatching('src/**', addonDir)).sort(),
9691
`ensure we don't pollute the src dir with declarations and emit the js and .d.ts to the correct folders -- this should be the same as the input files (no change from the fixture + default files)`,
9792
).toMatchInlineSnapshot(`
9893
[
94+
"src/components/another-gts.gts",
95+
"src/components/template-import.gts",
9996
"src/index.ts",
10097
"src/lint-test-gts.gts",
10198
"src/lint-test-ts.ts",
102-
"src/template-registry.ts",
103-
"src/components/another-gts.gts",
104-
"src/components/template-import.gts",
10599
"src/services/example.ts",
100+
"src/template-registry.ts",
106101
]
107102
`);
108103

109104
expect(
110-
await filesMatching('{dist,declarations}/**/*', addonDir),
105+
(await filesMatching('{dist,declarations}/**/*', addonDir)).sort(),
111106
`ensure we emit the correct files out of the box to the correct folders`,
112107
).toMatchInlineSnapshot(`
113108
[
114-
"dist/index.js",
115-
"dist/index.js.map",
116-
"dist/lint-test-gts.js",
117-
"dist/lint-test-gts.js.map",
118-
"dist/lint-test-ts.js",
119-
"dist/lint-test-ts.js.map",
120-
"dist/template-registry.js",
121-
"dist/template-registry.js.map",
122-
"dist/components/another-gts.js",
123-
"dist/components/another-gts.js.map",
124-
"dist/components/template-import.js",
125-
"dist/components/template-import.js.map",
126-
"dist/services/example.js",
127-
"dist/services/example.js.map",
128-
"dist/_app_/components/another-gts.js",
129-
"dist/_app_/components/template-import.js",
130-
"dist/_app_/services/example.js",
109+
"declarations/components/another-gts.d.ts",
110+
"declarations/components/another-gts.d.ts.map",
111+
"declarations/components/template-import.d.ts",
112+
"declarations/components/template-import.d.ts.map",
131113
"declarations/index.d.ts",
132114
"declarations/index.d.ts.map",
133115
"declarations/lint-test-gts.d.ts",
134116
"declarations/lint-test-gts.d.ts.map",
135117
"declarations/lint-test-ts.d.ts",
136118
"declarations/lint-test-ts.d.ts.map",
137-
"declarations/template-registry.d.ts",
138-
"declarations/template-registry.d.ts.map",
139-
"declarations/components/another-gts.d.ts",
140-
"declarations/components/another-gts.d.ts.map",
141-
"declarations/components/template-import.d.ts",
142-
"declarations/components/template-import.d.ts.map",
143119
"declarations/services/example.d.ts",
144120
"declarations/services/example.d.ts.map",
121+
"declarations/template-registry.d.ts",
122+
"declarations/template-registry.d.ts.map",
123+
"dist/_app_/components/another-gts.js",
124+
"dist/_app_/components/template-import.js",
125+
"dist/_app_/services/example.js",
126+
"dist/components/another-gts.js",
127+
"dist/components/another-gts.js.map",
128+
"dist/components/template-import.js",
129+
"dist/components/template-import.js.map",
130+
"dist/index.js",
131+
"dist/index.js.map",
132+
"dist/lint-test-gts.js",
133+
"dist/lint-test-gts.js.map",
134+
"dist/lint-test-ts.js",
135+
"dist/lint-test-ts.js.map",
136+
"dist/services/example.js",
137+
"dist/services/example.js.map",
138+
"dist/template-registry.js",
139+
"dist/template-registry.js.map",
145140
]
146141
`);
147142
});

0 commit comments

Comments
 (0)