Skip to content

Commit 8bd5652

Browse files
committed
add tests
1 parent 3a12e0a commit 8bd5652

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

CHANGELOG.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Security
1515

16-
- update dependency @types/node to v22.10.4. ([#68](https://git.justinelmore.dev/jelmore1674/build-changelog/pulls/68)) ([renovate-bot](https://git.justinelmore.dev/jelmore1674))
16+
- update dependency @types/node to v22.10.5. ([#69](https://git.justinelmore.dev/jelmore1674/build-changelog/pulls/69)) ([renovate-bot](https://git.justinelmore.dev/jelmore1674))
1717

1818
## [1.4.1] - 2025-01-02
1919

@@ -69,7 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6969
- Allow notice in changelog entries.
7070
- Author name to change. 🚀 ([#42](https://git.justinelmore.dev/jelmore1674/build-changelog/issues/42), [#47](https://git.justinelmore.dev/jelmore1674/build-changelog/pulls/47)) (Justin Elmore)
7171
- References to changes, ie. Commit Hashes, Pull Requests and Issues. 🚀 ([#41](https://git.justinelmore.dev/jelmore1674/build-changelog/issues/41), [#47](https://git.justinelmore.dev/jelmore1674/build-changelog/pulls/47)) (Justin Elmore)
72-
- Allow usage of github relase url when releases url is not set in the config file. ([#47](https://git.justinelmore.dev/jelmore1674/build-changelog/pulls/47)) (Justin Elmore)
72+
- Allow usage of github release url when releases url is not set in the config file. ([#47](https://git.justinelmore.dev/jelmore1674/build-changelog/pulls/47)) (Justin Elmore)
7373

7474
### Security
7575

@@ -95,7 +95,7 @@ _Initial Release_
9595

9696
### Security
9797

98-
- pin depencies
98+
- pin dependencies
9999
- update vitest monorepo to v2.1.8
100100
- update dependency vite-tsconfig-paths to v5.1.4
101101
- update pnpm to v9.15.1
@@ -142,7 +142,7 @@ _Initial Release_
142142

143143
### Changed
144144

145-
- Pipeline ammends previous commit.
145+
- Pipeline amends previous commit.
146146

147147
### Removed
148148

@@ -179,7 +179,7 @@ _Initial Release_
179179

180180
- Fixed the `init` command generating `test.toml`.
181181
- Fixed the fallback value not working as expected in prompt.
182-
- Fixed crash when there is no archive file by genrating archive on `init` command.
182+
- Fixed crash when there is no archive file by generating archive on `init` command.
183183

184184
## [0.3.0] - 2024-11-24
185185

@@ -272,7 +272,7 @@ _Initial Release_
272272

273273
### Fixed
274274

275-
- `breaking` flag not rendering in changelog correctly. Adds a hypen. to make it look better.
275+
- `breaking` flag not rendering in changelog correctly. Adds a hyphen. to make it look better.
276276

277277
## [0.0.6] - 2024-11-17
278278

@@ -284,10 +284,9 @@ _Initial Release_
284284

285285
### Added
286286

287-
- inital release of app.
287+
- initial release of app.
288288
- `breaking` keyword to show breaking changes.
289289

290-
291290
[Unreleased]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/vUnreleased
292291
[1.4.1]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/v1.4.1
293292
[1.4.0]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/v1.4.0
@@ -317,4 +316,5 @@ _Initial Release_
317316
[0.1.0]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/v0.1.0
318317
[0.0.7]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/v0.0.7
319318
[0.0.6]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/v0.0.6
320-
[0.0.5]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/v0.0.5
319+
[0.0.5]: https://git.justinelmore.dev/jelmore1674/build-changelog/releases/tag/v0.0.5
320+

src/lib/generate.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe("generateCommand", () => {
134134
expect(readdirSync(changelogDir).length).toBe(0);
135135
});
136136

137-
test("sucessfully runs the generate command", () => {
137+
test("successfully runs the generate command", () => {
138138
setupChanges();
139139
setupArchive();
140140

@@ -146,7 +146,7 @@ describe("generateCommand", () => {
146146
expect(generateCommand).toReturn();
147147
});
148148

149-
test("sucessfully runs the generate command", () => {
149+
test("successfully runs the generate command", () => {
150150
// Setup test changes files.
151151
const change = {
152152
version: "1.0.0",
@@ -163,7 +163,7 @@ describe("generateCommand", () => {
163163
expect(() => generate.generateCommand()).toThrowError();
164164
});
165165

166-
test("sucessfully runs the generate command", () => {
166+
test("successfully runs the generate command", () => {
167167
// Setup test changes files.
168168
const change = {
169169
version: "1.0.0",

src/lib/parseChangelog.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,30 @@ Here we would have the update steps for 1.2.4 for people to follow.
204204
added: ["[Breaking 🧨] - this cool change.", "[Breaking 🧨] - this other change here."],
205205
}]);
206206
});
207+
208+
test("can handle different variations of versions", () => {
209+
vi.spyOn(fs, "existsSync").mockReturnValue(true);
210+
vi.spyOn(fs, "readFileSync").mockReturnValueOnce(
211+
`# Changelog\n\n## [1.0.0-alpha] - 2024-12-07\n\n### Added\n\n- [Breaking 🧨] - this other change here.\n\n## [1.4.30] - 2024-12-07\n\n### Added\n\n- [Breaking 🧨] - this other change here.\n\n## [1.0.0] - 2024-12-07\n\n### Added\n\n- [Breaking 🧨] - this other change here.`,
212+
);
213+
const cl = parseChangelog("CHANGELOG.md");
214+
console.log({ cl });
215+
expect(cl).toEqual([
216+
{
217+
version: "1.0.0-alpha",
218+
release_date: "2024-12-07",
219+
added: ["[Breaking 🧨] - this other change here."],
220+
},
221+
{
222+
version: "1.4.30",
223+
release_date: "2024-12-07",
224+
added: ["[Breaking 🧨] - this other change here."],
225+
},
226+
{
227+
version: "1.0.0",
228+
release_date: "2024-12-07",
229+
added: ["[Breaking 🧨] - this other change here."],
230+
},
231+
]);
232+
});
207233
});

0 commit comments

Comments
 (0)