Skip to content

Commit 190e63c

Browse files
committed
modernise test helpers
1 parent 6a9bc2f commit 190e63c

3 files changed

Lines changed: 8 additions & 33 deletions

File tree

tests/helpers/assertions.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface AssertGeneratedOptions {
1515
testAppLocation?: string;
1616
testAppName?: string;
1717
expectedStaticFiles?: string[];
18-
packageManager?: 'npm' | 'yarn' | 'pnpm';
18+
packageManager?: string;
1919
typeScript?: boolean;
2020
existingMonorepo?: boolean;
2121
}
@@ -35,27 +35,10 @@ export async function assertGeneratedCorrectly({
3535
typeScript = false,
3636
existingMonorepo = false,
3737
}: AssertGeneratedOptions) {
38-
let addonPath = path.join(projectRoot, addonLocation ?? 'my-addon');
39-
let testAppPath = path.join(projectRoot, testAppLocation ?? 'test-app');
40-
38+
let addonPath = path.join(projectRoot);
4139
expect(await fse.pathExists(addonPath), `${addonPath} exists`).toBe(true);
42-
expect(await fse.pathExists(testAppPath), `${testAppPath} exists`).toBe(true);
43-
4440
let addonPackageJson = await packageJsonAt(addonPath);
45-
let testAppPackageJson = await packageJsonAt(testAppPath);
46-
4741
expect(addonPackageJson.name, `addon has correct name: ${addonName}`).toEqual(addonName);
48-
expect(testAppPackageJson.name, `testApp has correct name: ${testAppName ?? 'test-app'}`).toEqual(
49-
testAppName ?? 'test-app',
50-
);
51-
52-
expect(
53-
[
54-
...Object.keys(testAppPackageJson.dependencies || {}),
55-
...Object.keys(testAppPackageJson.devDependencies || {}),
56-
],
57-
`The test app has a (dev)dependency on the addon`,
58-
).to.include(addonName);
5942

6043
for (let expectedFile of expectedStaticFiles) {
6144
let pathToFile = path.join(addonPath, expectedFile);
@@ -84,7 +67,7 @@ interface AssertECUOptions {
8467
addonLocation?: string;
8568
testAppLocation?: string;
8669
testAppName?: string;
87-
packageManager: 'npm' | 'yarn' | 'pnpm';
70+
packageManager: string;
8871
typeScript: boolean;
8972
}
9073

@@ -105,11 +88,11 @@ export async function assertCorrectECUJson({
10588
expect(json.projectName).toEqual(addonName);
10689
expect(json.packages).toHaveLength(1);
10790

108-
expect(json.packages[0].name).toEqual('@embroider/addon-blueprint');
91+
expect(json.packages[0].name).toEqual('@ember/addon-blueprint');
10992
expect(json.packages[0].version).toEqual(ownPkg.version);
11093

11194
expect(json.packages[0].blueprints).toHaveLength(1);
112-
expect(json.packages[0].blueprints[0].name).toEqual('@embroider/addon-blueprint');
95+
expect(json.packages[0].blueprints[0].name).toEqual('@ember/addon-blueprint');
11396

11497
if (packageManager !== 'npm') {
11598
expect(json.packages[0].blueprints[0].options).toContain(`--${packageManager}`);

tests/helpers/meta-helpers.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ export class AddonHelper {
2424
#projectRoot?: string;
2525
#tmpDir?: string;
2626
#scenario: string;
27-
#packageManager: 'npm' | 'pnpm' | 'yarn';
28-
#addonFolder?: string;
27+
#packageManager: 'npm' | 'pnpm';
2928
#args: string[];
3029
#fixtures: AddonFixtureHelper | undefined;
3130

3231
constructor(options: {
3332
args?: string[];
3433
scenario?: string;
35-
packageManager: 'pnpm' | 'npm' | 'yarn';
34+
packageManager: 'pnpm' | 'npm';
3635
}) {
3736
this.#args = options.args || [];
3837
this.#scenario = options.scenario || 'default';
@@ -65,7 +64,6 @@ export class AddonHelper {
6564

6665
// this is the project root
6766
this.#projectRoot = path.join(this.#tmpDir, name);
68-
this.#addonFolder = path.join(this.#projectRoot, name);
6967

7068
this.#fixtures = new AddonFixtureHelper({ cwd: this.#projectRoot, scenario: this.#scenario });
7169
}
@@ -114,12 +112,6 @@ export class AddonHelper {
114112

115113
return this.#fixtures;
116114
}
117-
118-
get addonFolder() {
119-
assert(this.#addonFolder, 'Cannot get addon folder. Was the Addon Helper `setup`?');
120-
121-
return this.#addonFolder;
122-
}
123115
}
124116

125117
export class AddonFixtureHelper {

tests/helpers/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1111
// repo-root
1212
const blueprintPath = path.join(__dirname, '../..');
1313

14-
export const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'] as const;
14+
export const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'pnpm'] as const;
1515

1616
export async function createTmp() {
1717
let prefix = 'v2-addon-blueprint--';

0 commit comments

Comments
 (0)