Skip to content

Commit a546cb3

Browse files
naitokosukeclaude
andcommitted
test: add snapshot test for license file generation
Adds a characterization test that verifies THIRD-PARTY-LICENSES.md output using a snapshot, ensuring behavioral equivalence when replacing the license collection implementation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent adce49d commit a546cb3

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`obuild > license file matches snapshot 1`] = `
4+
"# Licenses of Bundled Dependencies
5+
6+
The published artifact additionally contains code with the following licenses:
7+
MIT
8+
9+
# Bundled Dependencies
10+
11+
## defu
12+
13+
License: MIT
14+
Repository: https://github.com/unjs/defu
15+
16+
> MIT License
17+
>
18+
> Copyright (c) Pooya Parsa <pooya@pi0.io>
19+
>
20+
> Permission is hereby granted, free of charge, to any person obtaining a copy
21+
> of this software and associated documentation files (the "Software"), to deal
22+
> in the Software without restriction, including without limitation the rights
23+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24+
> copies of the Software, and to permit persons to whom the Software is
25+
> furnished to do so, subject to the following conditions:
26+
>
27+
> The above copyright notice and this permission notice shall be included in all
28+
> copies or substantial portions of the Software.
29+
>
30+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36+
> SOFTWARE.
37+
"
38+
`;

test/obuild.test.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,8 @@ describe("obuild", () => {
7676
expect(stats.mode & 0o111).toBe(0o111); // Check if executable
7777
});
7878

79-
test("license file is generated with correct structure", async () => {
79+
test("license file matches snapshot", async () => {
8080
const content = await readFile(new URL("THIRD-PARTY-LICENSES.md", distDir), "utf8");
81-
expect(content).toContain("# Licenses of Bundled Dependencies");
82-
expect(content).toContain("# Bundled Dependencies");
83-
expect(content).toContain("MIT");
84-
});
85-
86-
test("license file contains bundled dependency info", async () => {
87-
const content = await readFile(new URL("THIRD-PARTY-LICENSES.md", distDir), "utf8");
88-
expect(content).toContain("## defu");
89-
expect(content).toContain("License: MIT");
90-
expect(content).toContain("Pooya Parsa");
91-
expect(content).toContain("> MIT License");
81+
expect(content).toMatchSnapshot();
9282
});
9383
});

0 commit comments

Comments
 (0)