Skip to content

Commit 27d60dd

Browse files
committed
test: test both possible values of excludeChoreDeps
1 parent eb22e54 commit 27d60dd

File tree

1 file changed

+200
-2
lines changed

1 file changed

+200
-2
lines changed

test/git.test.ts

Lines changed: 200 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getGitDiff,
55
loadChangelogConfig,
66
parseCommits,
7+
filterParsedCommits,
78
getRepoConfig,
89
formatReference,
910
} from "../src";
@@ -21,7 +22,7 @@ describe("git", () => {
2122
);
2223
});
2324

24-
test("parse", async () => {
25+
test("parse with default config", async () => {
2526
const COMMIT_FROM = "1cb15d5dd93302ebd5ff912079ed584efcc6703b";
2627
const COMMIT_TO = "3828bda8c45933396ddfa869d671473231ce3c95";
2728

@@ -117,7 +118,204 @@ describe("git", () => {
117118
from: COMMIT_FROM,
118119
to: COMMIT_TO,
119120
});
120-
const parsed = parseCommits(commits, config);
121+
const parsed = filterParsedCommits(parseCommits(commits, config), config);
122+
123+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
124+
expect(parsed.map(({ body: _, author: __, authors: ___, ...rest }) => rest))
125+
.toMatchInlineSnapshot(`
126+
[
127+
{
128+
"description": "v0.3.5",
129+
"isBreaking": false,
130+
"message": "chore(release): v0.3.5",
131+
"references": [
132+
{
133+
"type": "hash",
134+
"value": "3828bda",
135+
},
136+
],
137+
"scope": "release",
138+
"shortHash": "3828bda",
139+
"type": "chore",
140+
},
141+
{
142+
"description": "breaking change example, close #123",
143+
"isBreaking": true,
144+
"message": "fix(scope)!: breaking change example, close #123 (#134)",
145+
"references": [
146+
{
147+
"type": "pull-request",
148+
"value": "#134",
149+
},
150+
{
151+
"type": "issue",
152+
"value": "#123",
153+
},
154+
{
155+
"type": "hash",
156+
"value": "20e622e",
157+
},
158+
],
159+
"scope": "scope",
160+
"shortHash": "20e622e",
161+
"type": "fix",
162+
},
163+
{
164+
"description": "v0.3.4",
165+
"isBreaking": false,
166+
"message": "chore(release): v0.3.4",
167+
"references": [
168+
{
169+
"type": "hash",
170+
"value": "6fc5087",
171+
},
172+
],
173+
"scope": "release",
174+
"shortHash": "6fc5087",
175+
"type": "chore",
176+
},
177+
{
178+
"description": "infer github config from package.json",
179+
"isBreaking": false,
180+
"message": "feat: infer github config from package.json (resolves #37)",
181+
"references": [
182+
{
183+
"type": "pull-request",
184+
"value": "#37",
185+
},
186+
{
187+
"type": "hash",
188+
"value": "c0febf1",
189+
},
190+
],
191+
"scope": "",
192+
"shortHash": "c0febf1",
193+
"type": "feat",
194+
},
195+
{
196+
"description": "v0.3.3",
197+
"isBreaking": false,
198+
"message": "chore(release): v0.3.3",
199+
"references": [
200+
{
201+
"type": "hash",
202+
"value": "f4f42a3",
203+
},
204+
],
205+
"scope": "release",
206+
"shortHash": "f4f42a3",
207+
"type": "chore",
208+
},
209+
{
210+
"description": "consider docs and refactor as semver patch for bump",
211+
"isBreaking": false,
212+
"message": "fix: consider docs and refactor as semver patch for bump",
213+
"references": [
214+
{
215+
"type": "hash",
216+
"value": "648ccf1",
217+
},
218+
],
219+
"scope": "",
220+
"shortHash": "648ccf1",
221+
"type": "fix",
222+
},
223+
{
224+
"description": "expose \`determineSemverChange\` and \`bumpVersion\`",
225+
"isBreaking": false,
226+
"message": "feat: expose \`determineSemverChange\` and \`bumpVersion\`",
227+
"references": [
228+
{
229+
"type": "hash",
230+
"value": "5451f18",
231+
},
232+
],
233+
"scope": "",
234+
"shortHash": "5451f18",
235+
"type": "feat",
236+
},
237+
{
238+
"description": "fix typecheck",
239+
"isBreaking": false,
240+
"message": "chore: fix typecheck",
241+
"references": [
242+
{
243+
"type": "hash",
244+
"value": "8796cf1",
245+
},
246+
],
247+
"scope": "",
248+
"shortHash": "8796cf1",
249+
"type": "chore",
250+
},
251+
{
252+
"description": "update dependencies",
253+
"isBreaking": false,
254+
"message": "chore: update dependencies",
255+
"references": [
256+
{
257+
"type": "hash",
258+
"value": "c210976",
259+
},
260+
],
261+
"scope": "",
262+
"shortHash": "c210976",
263+
"type": "chore",
264+
},
265+
]
266+
`);
267+
268+
const md = await generateMarkDown(parsed, config);
269+
270+
expect(md).toMatchInlineSnapshot(`
271+
"## 1cb15d5dd93302ebd5ff912079ed584efcc6703b...3828bda8c45933396ddfa869d671473231ce3c95
272+
273+
[compare changes](https://github.com/unjs/changelogen/compare/1cb15d5dd93302ebd5ff912079ed584efcc6703b...3828bda8c45933396ddfa869d671473231ce3c95)
274+
275+
276+
### 🚀 Enhancements
277+
278+
- Expose \`determineSemverChange\` and \`bumpVersion\` ([5451f18](https://github.com/unjs/changelogen/commit/5451f18))
279+
- Infer github config from package.json ([#37](https://github.com/unjs/changelogen/pull/37))
280+
281+
### 🩹 Fixes
282+
283+
- Consider docs and refactor as semver patch for bump ([648ccf1](https://github.com/unjs/changelogen/commit/648ccf1))
284+
- **scope:** ⚠️ Breaking change example, close #123 ([#134](https://github.com/unjs/changelogen/pull/134), [#123](https://github.com/unjs/changelogen/issues/123))
285+
286+
### 🏡 Chore
287+
288+
- Update dependencies ([c210976](https://github.com/unjs/changelogen/commit/c210976))
289+
- Fix typecheck ([8796cf1](https://github.com/unjs/changelogen/commit/8796cf1))
290+
- **release:** V0.3.3 ([f4f42a3](https://github.com/unjs/changelogen/commit/f4f42a3))
291+
- **release:** V0.3.4 ([6fc5087](https://github.com/unjs/changelogen/commit/6fc5087))
292+
- **release:** V0.3.5 ([3828bda](https://github.com/unjs/changelogen/commit/3828bda))
293+
294+
#### ⚠️ Breaking Changes
295+
296+
- **scope:** ⚠️ Breaking change example, close #123 ([#134](https://github.com/unjs/changelogen/pull/134), [#123](https://github.com/unjs/changelogen/issues/123))
297+
298+
### ❤️ Contributors
299+
300+
- Pooya Parsa ([@pi0](http://github.com/pi0))"
301+
`);
302+
});
303+
304+
test("parse including chore(deps)", async () => {
305+
const COMMIT_FROM = "1cb15d5dd93302ebd5ff912079ed584efcc6703b";
306+
const COMMIT_TO = "3828bda8c45933396ddfa869d671473231ce3c95";
307+
308+
const commits = await getGitDiff(COMMIT_FROM, COMMIT_TO);
309+
commits[1].message =
310+
"fix(scope)!: breaking change example, close #123 (#134)";
311+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
312+
313+
const config = await loadChangelogConfig(process.cwd(), {
314+
from: COMMIT_FROM,
315+
to: COMMIT_TO,
316+
excludeChoreDeps: false,
317+
});
318+
const parsed = filterParsedCommits(parseCommits(commits, config), config);
121319

122320
// eslint-disable-next-line @typescript-eslint/no-unused-vars
123321
expect(parsed.map(({ body: _, author: __, authors: ___, ...rest }) => rest))

0 commit comments

Comments
 (0)