Skip to content

Commit 091dd8d

Browse files
committed
chore: add test for updateChangelog
1 parent f7a0f10 commit 091dd8d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/update-changelog.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import _outdent from 'outdent';
2+
3+
import { updateChangelog } from './update-changelog';
4+
5+
const outdent = _outdent({ trimTrailingNewline: false });
6+
7+
describe('updateChangelog', () => {
8+
it('should call git fetch by default', () => {
9+
const cmdMock = jest.fn();
10+
updateChangelog({
11+
changelogContent: outdent`
12+
# Changelog
13+
All notable changes to this project will be documented in this file.
14+
15+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
16+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
17+
18+
## [Unreleased]
19+
20+
[Unreleased]:https://github.com/ExampleUsernameOrOrganization/ExampleRepository/
21+
`,
22+
isReleaseCandidate: true,
23+
repoUrl:
24+
'https://github.com/ExampleUsernameOrOrganization/ExampleRepository',
25+
run: cmdMock,
26+
});
27+
expect(cmdMock).toHaveBeenCalledWith('git', ['fetch', '--tags'])
28+
});
29+
it('should not call git fetch when ', () => {
30+
const cmdMock = jest.fn();
31+
updateChangelog({
32+
changelogContent: outdent`
33+
# Changelog
34+
All notable changes to this project will be documented in this file.
35+
36+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
37+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
38+
39+
## [Unreleased]
40+
41+
[Unreleased]:https://github.com/ExampleUsernameOrOrganization/ExampleRepository/
42+
`,
43+
isReleaseCandidate: true,
44+
repoUrl:
45+
'https://github.com/ExampleUsernameOrOrganization/ExampleRepository',
46+
fetchRemote: false,
47+
run: cmdMock,
48+
});
49+
expect(cmdMock).not.toHaveBeenCalledWith(['git'], ['fetch', '--tags'])
50+
});
51+
});

0 commit comments

Comments
 (0)