Skip to content

Commit f7804de

Browse files
committed
fix(coverage): pass the appropriate input to the codecov scaffolder
1 parent 70c5b17 commit f7804de

File tree

10 files changed

+17
-69
lines changed

10 files changed

+17
-69
lines changed

src/coverage/scaffolder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import deepmerge from 'deepmerge';
22
import {scaffold as scaffoldCodecov} from '@form8ion/codecov';
33
import {scaffold as scaffoldC8} from '@form8ion/c8';
44

5-
export default async function scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent}) {
6-
return deepmerge(await scaffoldC8({projectRoot}), await scaffoldCodecov({vcs, visibility, pathWithinParent}));
5+
export default async function scaffoldCoverage({projectRoot}) {
6+
return deepmerge(await scaffoldC8({projectRoot}), await scaffoldCodecov({projectRoot}));
77
}

src/coverage/scaffolder.test.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {scaffold as scaffoldCodecov} from '@form8ion/codecov';
22
import {scaffold as scaffoldC8} from '@form8ion/c8';
33

4-
import {describe, vi, it, expect, afterEach} from 'vitest';
4+
import {describe, expect, it, vi} from 'vitest';
55
import any from '@travi/any';
66
import {when} from 'vitest-when';
77

@@ -11,21 +11,14 @@ vi.mock('@form8ion/codecov');
1111
vi.mock('@form8ion/c8');
1212

1313
describe('coverage scaffolder', () => {
14-
afterEach(() => {
15-
vi.clearAllMocks();
16-
});
17-
1814
it('should scaffold coverage measurement and reporting', async () => {
19-
const vcs = any.simpleObject();
20-
const visibility = any.word();
2115
const projectRoot = any.string();
2216
const c8Results = any.simpleObject();
2317
const codecovResults = any.simpleObject();
24-
const pathWithinParent = any.string();
2518
when(scaffoldC8).calledWith({projectRoot}).thenResolve(c8Results);
26-
when(scaffoldCodecov).calledWith({vcs, visibility, pathWithinParent}).thenResolve(codecovResults);
19+
when(scaffoldCodecov).calledWith({projectRoot}).thenResolve(codecovResults);
2720

28-
const results = await scaffold({vcs, visibility, projectRoot, pathWithinParent});
21+
const results = await scaffold({projectRoot});
2922

3023
expect(results).toEqual({...c8Results, ...codecovResults});
3124
});

src/scaffolder.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export default async function scaffoldJavascript(options) {
8989
const verificationResults = await scaffoldVerification({
9090
projectRoot,
9191
dialect,
92-
visibility,
9392
packageManager,
9493
vcs,
9594
registries: configs.registries,

src/scaffolder.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ describe('javascript project scaffolder', () => {
155155
.calledWith({
156156
projectRoot,
157157
dialect,
158-
visibility,
159158
packageManager,
160159
vcs,
161160
registries,

src/testing/scaffolder.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,13 @@ import {scaffold as scaffoldUnitTesting} from './unit/index.js';
44

55
export default async function scaffoldTesting({
66
projectRoot,
7-
visibility,
87
tests: {unit, integration},
9-
vcs,
108
unitTestFrameworks,
119
decisions,
12-
dialect,
13-
pathWithinParent
10+
dialect
1411
}) {
1512
const unitResults = unit
16-
? await scaffoldUnitTesting({
17-
projectRoot,
18-
visibility,
19-
vcs,
20-
frameworks: unitTestFrameworks,
21-
decisions,
22-
dialect,
23-
pathWithinParent
24-
})
13+
? await scaffoldUnitTesting({projectRoot, frameworks: unitTestFrameworks, decisions, dialect})
2514
: {};
2615

2716
return deepmerge(

src/testing/scaffolder.test.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,18 @@ vi.mock('./unit/index.js');
99

1010
describe('testing scaffolder', () => {
1111
const projectRoot = any.string();
12-
const visibility = any.word();
1312
const dialect = any.word();
1413
const unitTestingDevDependencies = any.listOf(any.string);
1514
const unitTestNextSteps = any.listOf(any.simpleObject);
1615
const unitTestScripts = any.simpleObject();
1716
const unitTestFilesToIgnoreFromVcs = any.listOf(any.string);
1817
const unitTestDirectoriesToIgnoreFromVcs = any.listOf(any.string);
19-
const vcs = any.simpleObject();
2018
const unitTestFrameworks = any.simpleObject();
2119
const decisions = any.simpleObject();
22-
const pathWithinParent = any.string();
2320

2421
beforeEach(() => {
2522
when(scaffoldUnitTesting)
26-
.calledWith({projectRoot, visibility, vcs, frameworks: unitTestFrameworks, decisions, dialect, pathWithinParent})
23+
.calledWith({projectRoot, frameworks: unitTestFrameworks, decisions, dialect})
2724
.thenResolve({
2825
dependencies: {javascript: {development: unitTestingDevDependencies}},
2926
scripts: unitTestScripts,
@@ -35,13 +32,10 @@ describe('testing scaffolder', () => {
3532
it('should scaffold unit testing if the project will be unit test', async () => {
3633
expect(await scaffoldTesting({
3734
projectRoot,
38-
visibility,
3935
tests: {unit: true},
40-
vcs,
4136
unitTestFrameworks,
4237
decisions,
43-
dialect,
44-
pathWithinParent
38+
dialect
4539
})).toEqual({
4640
dependencies: {javascript: {development: ['@travi/any', ...unitTestingDevDependencies]}},
4741
scripts: unitTestScripts,
@@ -52,12 +46,12 @@ describe('testing scaffolder', () => {
5246
});
5347

5448
it('should not scaffold unit testing if the project will not be unit tested', async () => {
55-
expect(await scaffoldTesting({projectRoot, visibility, tests: {unit: false, integration: true}, pathWithinParent}))
49+
expect(await scaffoldTesting({projectRoot, tests: {unit: false, integration: true}}))
5650
.toEqual({dependencies: {javascript: {development: ['@travi/any']}}, eslint: {}});
5751
});
5852

5953
it('should not scaffold testing if the project will not be tested', async () => {
60-
expect(await scaffoldTesting({projectRoot, visibility, tests: {unit: false, integration: false}, pathWithinParent}))
54+
expect(await scaffoldTesting({projectRoot, tests: {unit: false, integration: false}}))
6155
.toEqual({dependencies: {javascript: {development: []}}, eslint: {}});
6256
});
6357
});

src/testing/unit/scaffolder.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,12 @@ import {scaffold as scaffoldCoverage} from '../../coverage/index.js';
66
import chooseFramework from './prompt.js';
77
import {pluginsSchema} from '../../plugins-schemas.js';
88

9-
export default async function scaffoldUnitTesting({
10-
projectRoot,
11-
frameworks,
12-
decisions,
13-
visibility,
14-
vcs,
15-
pathWithinParent,
16-
dialect
17-
}) {
9+
export default async function scaffoldUnitTesting({projectRoot, frameworks, decisions, dialect}) {
1810
const validatedFrameworks = validateOptions(pluginsSchema, frameworks);
1911
const [framework, coverage] = await Promise.all([
2012
chooseFramework({frameworks: validatedFrameworks, decisions})
2113
.then(chosenFramework => scaffoldFrameworkChoice(validatedFrameworks, chosenFramework, {projectRoot, dialect})),
22-
scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent})
14+
scaffoldCoverage({projectRoot})
2315
]);
2416

2517
return deepmerge.all([

src/testing/unit/scaffolder.test.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,22 @@ vi.mock('./prompt.js');
1919

2020
describe('unit testing scaffolder', () => {
2121
const projectRoot = any.string();
22-
const vcs = any.simpleObject();
2322
const frameworks = any.simpleObject();
2423
const decisions = any.simpleObject();
2524
const chosenFramework = any.word();
2625
const dialect = any.word();
27-
const pathWithinParent = any.string();
2826
const coverageResults = any.simpleObject();
2927
const unitTestFrameworkResults = any.simpleObject();
3028
const mergedResults = any.simpleObject();
3129

3230
it('should scaffold the chosen framework', async () => {
33-
const visibility = any.word();
3431
const validatedFrameworks = any.simpleObject();
3532
when(validateOptions).calledWith(pluginsSchema, frameworks).thenReturn(validatedFrameworks);
3633
when(prompt).calledWith({frameworks: validatedFrameworks, decisions}).thenResolve(chosenFramework);
3734
when(scaffoldChoice)
3835
.calledWith(validatedFrameworks, chosenFramework, {projectRoot, dialect})
3936
.thenResolve(unitTestFrameworkResults);
40-
when(scaffoldCoverage)
41-
.calledWith({projectRoot, vcs, visibility, pathWithinParent})
42-
.thenResolve(coverageResults);
37+
when(scaffoldCoverage).calledWith({projectRoot}).thenResolve(coverageResults);
4338
when(deepmerge.all)
4439
.calledWith([
4540
{scripts: {'test:unit': 'cross-env NODE_ENV=test c8 run-s test:unit:base'}},
@@ -48,7 +43,6 @@ describe('unit testing scaffolder', () => {
4843
])
4944
.thenReturn(mergedResults);
5045

51-
expect(await scaffoldUnitTesting({projectRoot, frameworks, decisions, vcs, visibility, pathWithinParent, dialect}))
52-
.toEqual(mergedResults);
46+
expect(await scaffoldUnitTesting({projectRoot, frameworks, decisions, dialect})).toEqual(mergedResults);
5347
});
5448
});

src/verification/scaffolder.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {scaffold as scaffoldLinting} from '../linting/index.js';
77
export async function scaffoldVerification({
88
projectRoot,
99
dialect,
10-
visibility,
1110
packageManager,
1211
vcs,
1312
registries,
@@ -17,16 +16,7 @@ export async function scaffoldVerification({
1716
pathWithinParent
1817
}) {
1918
const [testingResults, lintingResults, huskyResults] = await Promise.all([
20-
scaffoldTesting({
21-
projectRoot,
22-
tests,
23-
visibility,
24-
vcs,
25-
unitTestFrameworks,
26-
decisions,
27-
dialect,
28-
pathWithinParent
29-
}),
19+
scaffoldTesting({projectRoot, tests, unitTestFrameworks, decisions, dialect}),
3020
scaffoldLinting({projectRoot, packageManager, registries, vcs, pathWithinParent}),
3121
scaffoldHusky({projectRoot, packageManager, pathWithinParent})
3222
]);

src/verification/scaffolder.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ vi.mock('../linting/index.js');
1717
describe('verification scaffolder', () => {
1818
it('should scaffold linting and testing', async () => {
1919
const projectRoot = any.string();
20-
const visibility = any.string();
2120
const packageManager = any.string();
2221
const dialect = any.word();
2322
const vcs = any.simpleObject();
@@ -35,7 +34,7 @@ describe('verification scaffolder', () => {
3534
.calledWith({projectRoot, vcs, packageManager, registries, pathWithinParent})
3635
.thenResolve(lintingResults);
3736
when(scaffoldTesting)
38-
.calledWith({projectRoot, tests, visibility, vcs, unitTestFrameworks, decisions, dialect, pathWithinParent})
37+
.calledWith({projectRoot, tests, unitTestFrameworks, decisions, dialect})
3938
.thenResolve(testingResults);
4039
when(scaffoldHusky).calledWith({projectRoot, packageManager, pathWithinParent}).thenResolve(huskyResults);
4140
when(deepmerge.all).calledWith([testingResults, lintingResults, huskyResults]).thenReturn(mergedResults);
@@ -45,7 +44,6 @@ describe('verification scaffolder', () => {
4544
vcs,
4645
dialect,
4746
tests,
48-
visibility,
4947
decisions,
5048
unitTestFrameworks,
5149
packageManager,

0 commit comments

Comments
 (0)