Skip to content

Commit 3d1bf48

Browse files
committed
fix(tests): wrong path
1 parent 6a019dd commit 3d1bf48

File tree

2 files changed

+61
-37
lines changed

2 files changed

+61
-37
lines changed

steps/01-jsx/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ npm run 01-jsx
2020
- display it in Card
2121

2222
3. Find out how to express style in JSX
23+
24+
4. (Bonus) Use Mui components for the card
25+
26+
```typescript
27+
import MuiCard from '@mui/material/Card';
28+
import MuiCardContent from '@mui/material/CardContent';
29+
import MuiTypography from '@mui/material/Typography';
30+
```

tests/steps.test.ts

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,111 @@
1-
import { describe, expect, it } from 'vitest';
2-
import fs from 'node:fs';
3-
import path from 'node:path';
4-
import packageJson from '../steps/package.json';
1+
import { describe, expect, it } from "vitest";
2+
import fs from "node:fs";
3+
import path from "node:path";
4+
import packageJson from "../steps/package.json";
55

6-
const STEPS_PATH = '../steps';
6+
const STEPS_PATH = "../steps";
77

8-
const DIR_NOT_A_PROJECT = ['node_modules', 'common'];
9-
const PROJECT_NOT_A_STEP = ['api'];
8+
const DIR_NOT_A_PROJECT = ["node_modules", "common"];
9+
const PROJECT_NOT_A_STEP = ["api"];
1010

11-
describe('every project should be declared in the workspace', () => {
11+
describe("every project should be declared in the workspace", () => {
1212
const projectsDir = getProjectsDir();
13-
it.each(projectsDir)('%s', (stepDir) => {
13+
it.each(projectsDir)("%s", (stepDir) => {
1414
expect(packageJson.workspaces.includes(stepDir)).toBeTruthy();
1515
});
1616
});
1717

18-
describe('every project should have a dedicated script with the same name', () => {
18+
describe("every project should have a dedicated script with the same name", () => {
1919
const projectsDir = getProjectsDir();
20-
it.each(projectsDir)('%s', (stepDir) => {
20+
it.each(projectsDir)("%s", (stepDir) => {
2121
expect(packageJson.scripts[stepDir]).toBeDefined();
2222
});
2323
});
2424

2525
describe("project's package.json name should have same name as the directory", () => {
2626
const projectsDir = getProjectsDir();
27-
it.each(projectsDir)('%s', (stepDir) => {
27+
it.each(projectsDir)("%s", (stepDir) => {
2828
const projectPackageJsonText = fs.readFileSync(
29-
path.resolve(path.join(STEPS_PATH, stepDir, 'package.json')),
30-
'utf-8'
29+
path.resolve(path.join(STEPS_PATH, stepDir, "package.json")),
30+
"utf-8",
3131
);
3232
const projectPackageJson = JSON.parse(projectPackageJsonText);
3333
expect(projectPackageJson.name).toBe(stepDir);
3434
});
3535
});
3636

37-
describe('every step should have a solution project', () => {
37+
describe("every step should have a solution project", () => {
3838
const projectsDir = getProjectsDir();
3939
const stepsDir = projectsDir
4040
.filter((dir) => PROJECT_NOT_A_STEP.every((d) => !dir.endsWith(d)))
41-
.filter((dir) => !dir.endsWith('-solution'));
42-
it.each(stepsDir)('%s', (stepDir) => {
43-
const solutionDir = stepDir + '-solution';
41+
.filter((dir) => !dir.endsWith("-solution"));
42+
it.each(stepsDir)("%s", (stepDir) => {
43+
const solutionDir = stepDir + "-solution";
4444
expect(projectsDir.includes(solutionDir)).toBeTruthy();
4545
});
4646
});
4747

48-
describe('every solution should have same name as step with -solution suffix', () => {
48+
describe("every solution should have same name as step with -solution suffix", () => {
4949
const stepsDir = getProjectsDir();
50-
const solutionStepsDir = stepsDir.filter((dir) => dir.endsWith('-solution'));
51-
it.each(solutionStepsDir)('%s', (solutionStepDir) => {
52-
const stepDir = solutionStepDir.slice(0, -'-solution'.length);
50+
const solutionStepsDir = stepsDir.filter((dir) => dir.endsWith("-solution"));
51+
it.each(solutionStepsDir)("%s", (solutionStepDir) => {
52+
const stepDir = solutionStepDir.slice(0, -"-solution".length);
5353
expect(stepsDir.includes(stepDir)).toBeTruthy();
5454
});
5555
});
5656

5757
describe("solution's README.md should be identical to exercise's one", () => {
5858
const stepsDir = getProjectsDir();
59-
const solutionStepsDir = stepsDir.filter((dir) => dir.endsWith('-solution'));
60-
it.each(solutionStepsDir)('%s', (solutionStepDir) => {
61-
const stepDir = solutionStepDir.slice(0, -'-solution'.length);
62-
const stepReadme = fs.readFileSync(path.resolve(path.join(STEPS_PATH, stepDir, 'README.md')), 'utf-8');
63-
const solutionReadme = fs.readFileSync(path.resolve(path.join(STEPS_PATH, stepDir, 'README.md')), 'utf-8');
59+
const solutionStepsDir = stepsDir.filter((dir) => dir.endsWith("-solution"));
60+
it.each(solutionStepsDir)("%s", (solutionStepDir) => {
61+
const stepDir = solutionStepDir.slice(0, -"-solution".length);
62+
const stepReadme = fs.readFileSync(
63+
path.resolve(path.join(STEPS_PATH, stepDir, "README.md")),
64+
"utf-8",
65+
);
66+
const solutionReadme = fs.readFileSync(
67+
path.resolve(path.join(STEPS_PATH, solutionStepDir, "README.md")),
68+
"utf-8",
69+
);
6470
expect(stepReadme).toStrictEqual(solutionReadme);
6571
});
6672
});
6773

68-
describe('exercise README.md should point out the correct command', () => {
74+
describe("exercise README.md should point out the correct command", () => {
6975
const projectsDir = getProjectsDir();
7076
const stepsDir = projectsDir
7177
.filter((dir) => PROJECT_NOT_A_STEP.every((d) => !dir.endsWith(d)))
72-
.filter((dir) => !dir.endsWith('-solution'));
73-
it.each(stepsDir)('%s', (stepDir) => {
74-
const stepReadme = fs.readFileSync(path.resolve(path.join(STEPS_PATH, stepDir, 'README.md')), 'utf-8');
78+
.filter((dir) => !dir.endsWith("-solution"));
79+
it.each(stepsDir)("%s", (stepDir) => {
80+
const stepReadme = fs.readFileSync(
81+
path.resolve(path.join(STEPS_PATH, stepDir, "README.md")),
82+
"utf-8",
83+
);
7584
expect(stepReadme).toContain(`npm run ${stepDir}`);
7685
});
7786
});
7887

79-
describe('exercise README.md should have the correct title', () => {
88+
describe("exercise README.md should have the correct title", () => {
8089
const projectsDir = getProjectsDir();
8190
const stepsDir = projectsDir
8291
.filter((dir) => PROJECT_NOT_A_STEP.every((d) => !dir.endsWith(d)))
83-
.filter((dir) => !dir.endsWith('-solution'));
84-
it.each(stepsDir)('%s', (stepDir) => {
85-
const stepReadme = fs.readFileSync(path.resolve(path.join(STEPS_PATH, stepDir, 'README.md')), 'utf-8');
86-
expect(stepReadme.split('\n')[0]).toStrictEqual(`# ${stepDir} instructions`);
92+
.filter((dir) => !dir.endsWith("-solution"));
93+
it.each(stepsDir)("%s", (stepDir) => {
94+
const stepReadme = fs.readFileSync(
95+
path.resolve(path.join(STEPS_PATH, stepDir, "README.md")),
96+
"utf-8",
97+
);
98+
expect(stepReadme.split("\n")[0]).toStrictEqual(
99+
`# ${stepDir} instructions`,
100+
);
87101
});
88102
});
89103

90104
function getProjectsDir() {
91105
return fs
92106
.readdirSync(path.resolve(STEPS_PATH))
93107
.filter((dir) => DIR_NOT_A_PROJECT.every((d) => !dir.endsWith(d)))
94-
.filter((dir) => fs.statSync(path.resolve(path.join(STEPS_PATH, dir))).isDirectory());
108+
.filter((dir) =>
109+
fs.statSync(path.resolve(path.join(STEPS_PATH, dir))).isDirectory()
110+
);
95111
}

0 commit comments

Comments
 (0)