|
| 1 | +import { testBlock } from "create-testers"; |
| 2 | +import { describe, expect, test, vi } from "vitest"; |
| 3 | + |
| 4 | +import { blockKnip } from "./blockKnip.js"; |
| 5 | +import { optionsBase } from "./options.fakes.js"; |
| 6 | + |
| 7 | +vi.mock("../utils/resolveBin.js", () => ({ |
| 8 | + resolveBin: (bin: string) => `path/to/${bin}`, |
| 9 | +})); |
| 10 | + |
| 11 | +describe("blockKnip", () => { |
| 12 | + test("without addons", () => { |
| 13 | + const creation = testBlock(blockKnip, { |
| 14 | + options: optionsBase, |
| 15 | + }); |
| 16 | + |
| 17 | + expect(creation).toMatchInlineSnapshot(` |
| 18 | + { |
| 19 | + "addons": [ |
| 20 | + { |
| 21 | + "addons": { |
| 22 | + "sections": { |
| 23 | + "Linting": { |
| 24 | + "contents": { |
| 25 | + "items": [ |
| 26 | + "- \`pnpm lint:knip\` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports", |
| 27 | + ], |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + }, |
| 32 | + "block": [Function], |
| 33 | + }, |
| 34 | + { |
| 35 | + "addons": { |
| 36 | + "jobs": [ |
| 37 | + { |
| 38 | + "name": "Lint Knip", |
| 39 | + "steps": [ |
| 40 | + { |
| 41 | + "run": "pnpm lint:knip", |
| 42 | + }, |
| 43 | + ], |
| 44 | + }, |
| 45 | + ], |
| 46 | + }, |
| 47 | + "block": [Function], |
| 48 | + }, |
| 49 | + { |
| 50 | + "addons": { |
| 51 | + "properties": { |
| 52 | + "devDependencies": { |
| 53 | + "knip": "5.41.1", |
| 54 | + }, |
| 55 | + "scripts": { |
| 56 | + "lint:knip": "knip", |
| 57 | + }, |
| 58 | + }, |
| 59 | + }, |
| 60 | + "block": [Function], |
| 61 | + }, |
| 62 | + ], |
| 63 | + "files": { |
| 64 | + "knip.json": "{"$schema":"https://unpkg.com/[email protected]/schema.json","entry":["src/index.ts"],"ignoreExportsUsedInFile":{"interface":true,"type":true},"project":["src/**/*.ts"]}", |
| 65 | + }, |
| 66 | + } |
| 67 | + `); |
| 68 | + }); |
| 69 | + |
| 70 | + test("with addons", () => { |
| 71 | + const creation = testBlock(blockKnip, { |
| 72 | + addons: { |
| 73 | + ignoreDependencies: ["abc", "def"], |
| 74 | + }, |
| 75 | + options: optionsBase, |
| 76 | + }); |
| 77 | + |
| 78 | + expect(creation).toMatchInlineSnapshot(` |
| 79 | + { |
| 80 | + "addons": [ |
| 81 | + { |
| 82 | + "addons": { |
| 83 | + "sections": { |
| 84 | + "Linting": { |
| 85 | + "contents": { |
| 86 | + "items": [ |
| 87 | + "- \`pnpm lint:knip\` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports", |
| 88 | + ], |
| 89 | + }, |
| 90 | + }, |
| 91 | + }, |
| 92 | + }, |
| 93 | + "block": [Function], |
| 94 | + }, |
| 95 | + { |
| 96 | + "addons": { |
| 97 | + "jobs": [ |
| 98 | + { |
| 99 | + "name": "Lint Knip", |
| 100 | + "steps": [ |
| 101 | + { |
| 102 | + "run": "pnpm lint:knip", |
| 103 | + }, |
| 104 | + ], |
| 105 | + }, |
| 106 | + ], |
| 107 | + }, |
| 108 | + "block": [Function], |
| 109 | + }, |
| 110 | + { |
| 111 | + "addons": { |
| 112 | + "properties": { |
| 113 | + "devDependencies": { |
| 114 | + "knip": "5.41.1", |
| 115 | + }, |
| 116 | + "scripts": { |
| 117 | + "lint:knip": "knip", |
| 118 | + }, |
| 119 | + }, |
| 120 | + }, |
| 121 | + "block": [Function], |
| 122 | + }, |
| 123 | + ], |
| 124 | + "files": { |
| 125 | + "knip.json": "{"$schema":"https://unpkg.com/[email protected]/schema.json","entry":["src/index.ts"],"ignoreDependencies":["abc","def"],"ignoreExportsUsedInFile":{"interface":true,"type":true},"project":["src/**/*.ts"]}", |
| 126 | + }, |
| 127 | + } |
| 128 | + `); |
| 129 | + }); |
| 130 | +}); |
0 commit comments