Skip to content

Commit 97e24fc

Browse files
committed
test: run monorepo tests with various directory names
1 parent 7778ab6 commit 97e24fc

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/main.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,56 @@ describe('main', () => {
4141
});
4242
});
4343

44+
for (const [description, directoryPath] of [
45+
['directories with spaces', '/path/to/my project'],
46+
['directories with quote', "/path/to/my 'project"],
47+
['directories with quotes', "/path/to/my 'proje'ct"],
48+
['directories with double-quote', '/path/to/my "project'],
49+
['directories with double-quotes', '/path/to/my "proje"ct'],
50+
[
51+
'directories with special characters',
52+
'/path/~to/#my/!y \'\\"\\pr@j/e"ct',
53+
],
54+
]) {
55+
const tempDirectoryPath = directoryPath.replace(/^\/path\//u, '/tmp/');
56+
const cwd = directoryPath.replace(/^\/path\//u, '/workdir/');
57+
it(`executes the monorepo workflow for ${description}`, async () => {
58+
const project = buildMockProject({
59+
directoryPath,
60+
isMonorepo: true,
61+
});
62+
const stdout = fs.createWriteStream('/dev/null');
63+
const stderr = fs.createWriteStream('/dev/null');
64+
jest
65+
.spyOn(initialParametersModule, 'determineInitialParameters')
66+
.mockResolvedValue({
67+
project,
68+
tempDirectoryPath,
69+
reset: true,
70+
releaseType: 'backport',
71+
});
72+
const followMonorepoWorkflowSpy = jest
73+
.spyOn(monorepoWorkflowOperations, 'followMonorepoWorkflow')
74+
.mockResolvedValue();
75+
76+
await main({
77+
argv: [],
78+
cwd,
79+
stdout,
80+
stderr,
81+
});
82+
83+
expect(followMonorepoWorkflowSpy).toHaveBeenCalledWith({
84+
project,
85+
tempDirectoryPath,
86+
firstRemovingExistingReleaseSpecification: true,
87+
releaseType: 'backport',
88+
stdout,
89+
stderr,
90+
});
91+
});
92+
}
93+
4494
it('executes the polyrepo workflow if the project is within a polyrepo', async () => {
4595
const project = buildMockProject({ isMonorepo: false });
4696
const stdout = fs.createWriteStream('/dev/null');

0 commit comments

Comments
 (0)