Skip to content

Commit a36672e

Browse files
committed
test(shadcn): Add registry spec tests
1 parent 79b8ff9 commit a36672e

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

packages/shadcn/registry-spec.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
"name": "acme",
44
"homepage": "{{ DOMAIN }}",
55
"items": [
6+
{
7+
"name": "sign-in-auth-screen",
8+
"type": "registry:block",
9+
"title": "Sign In Auth Screen",
10+
"description": "A screen allowing users to sign in with email and password.",
11+
"dependencies": ["{{ DEP | @firebase-ui/react }}"],
12+
"registryDependencies": ["separator", "card", "{{ DOMAIN }}/sign-in-auth-form.json"],
13+
"files": [
14+
{
15+
"path": "src/registry/sign-in-auth-screen.tsx",
16+
"type": "registry:component"
17+
}
18+
]
19+
},
620
{
721
"name": "sign-in-auth-form",
822
"type": "registry:block",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, it, expect, vi, afterEach, beforeEach } from "vitest";
2+
import fs from "fs";
3+
4+
const regisryFiles = import.meta.glob([
5+
"./src/registry/**/*.tsx",
6+
"!./src/registry/**/*.test.tsx",
7+
"!./src/registry/**/*.spec.tsx",
8+
]);
9+
10+
describe("registry-spec", () => {
11+
it("should be a valid JSON file", () => {
12+
const registrySpec = fs.readFileSync("./registry-spec.json", "utf8");
13+
expect(registrySpec).toBeDefined();
14+
expect(() => JSON.parse(registrySpec)).not.toThrow();
15+
});
16+
17+
for (const path of Object.keys(regisryFiles)) {
18+
it(`${path} should exist in the registry`, () => {
19+
const registrySpec = fs.readFileSync("./registry-spec.json", "utf8");
20+
const json = JSON.parse(registrySpec);
21+
22+
const name = path.split("/").at(-1)?.split(".")[0];
23+
const item = json.items.find((item: any) => item.name === name);
24+
expect(item).toBeDefined();
25+
});
26+
}
27+
});

0 commit comments

Comments
 (0)