Skip to content

Commit 1565b3a

Browse files
committed
test(unit): conver test for the commitizen scaffolder to vitest
for #458
1 parent d75f5be commit 1565b3a

File tree

3 files changed

+37
-48
lines changed

3 files changed

+37
-48
lines changed

src/commitizen-test.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/commitizen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {promises as fsPromises} from 'fs';
1+
import {promises as fs} from 'node:fs';
22

33
export default async function ({projectRoot}) {
4-
await fsPromises.writeFile(
4+
await fs.writeFile(
55
`${projectRoot}/.czrc`,
66
JSON.stringify({path: './node_modules/cz-conventional-changelog'})
77
);

src/commitizen.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {promises as fs} from 'node:fs';
2+
3+
import any from '@travi/any';
4+
import {it, describe, vi, expect} from 'vitest';
5+
6+
import scaffold from './commitizen.js';
7+
8+
vi.mock('node:fs');
9+
10+
describe('commitizen scaffolder', () => {
11+
it('should write the config file and define dependencies', async () => {
12+
const projectRoot = any.string();
13+
14+
const result = await scaffold({projectRoot});
15+
16+
expect(fs.writeFile)
17+
.toHaveBeenCalledWith(
18+
`${projectRoot}/.czrc`,
19+
JSON.stringify({path: './node_modules/cz-conventional-changelog'})
20+
);
21+
expect(result)
22+
.toEqual({
23+
dependencies: {javascript: {development: ['cz-conventional-changelog']}},
24+
badges: {
25+
contribution: {
26+
commitizen: {
27+
img: 'https://img.shields.io/badge/commitizen-friendly-brightgreen.svg',
28+
text: 'Commitizen friendly',
29+
link: 'http://commitizen.github.io/cz-cli/'
30+
}
31+
}
32+
}
33+
});
34+
});
35+
});

0 commit comments

Comments
 (0)