Skip to content

Commit

Permalink
Move to turborepo (#48)
Browse files Browse the repository at this point in the history
* 🧱 Init turbo-repo

* πŸ—οΈ Init turbo-repo

* πŸ™ˆ ignore node_modules in packages/ui
  • Loading branch information
damien-schneider authored Oct 22, 2024
1 parent d7f4bdc commit 205f56e
Show file tree
Hide file tree
Showing 937 changed files with 19,288 additions and 16,650 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
working-directory: apps/website

# - run: pnpm build
- name: Run tests
run: pnpm test
run: pnpm test
working-directory: apps/website
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js
/.yarn
Expand Down Expand Up @@ -35,3 +35,7 @@ yarn-error.log*

# typescript
*.tsbuildinfo

.turbo

dist
101 changes: 0 additions & 101 deletions __tests__/components/component-categories.test.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions __tests__/home-h1.test.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions __tests__/sidemenu.test.tsx

This file was deleted.

File renamed without changes.
39 changes: 39 additions & 0 deletions apps/website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
/.yarn

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*
!.env*.example

# vercel
.vercel

# typescript
*.tsbuildinfo

.turbo
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
101 changes: 101 additions & 0 deletions apps/website/__tests__/components/component-categories.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { describe, expect, it } from "vitest";
import { SectionsList } from "@cuicui/ui";
import { getFileContentAsString } from "#/src/utils/get-file-content-as-string";

describe("SectionsList", () => {
it("should have the correct number of sections", () => {
expect(SectionsList).toHaveLength(7);
});

it("should have the correct section slugs in the good order", () => {
const sectionSlugs = SectionsList.map((section) => section.slug);
expect(sectionSlugs).toEqual([
"common-ui",
"application-ui",
"marketing-ui",
"other",
"hooks",
"utils",
"tools",
]);
});

it("category should have componentList === null if comingSoonCategory === true", () => {
for (const section of SectionsList) {
if (section.type !== "multiple-component") {
continue;
}
//TODO: Handle the single-component test
for (const category of section.categoriesList) {
if (category.comingSoonCategory) {
expect(category.componentList).toBeNull();
expect(category.componentList).not.toBeUndefined();
}
}
}
});

it("should not return error when reading the file code", async () => {
const testComponentCode = async (
slug: string,
variantName: string,
shouldError: boolean,
) => {
const code = await getFileContentAsString({
componentSlug: slug,
variantName,
});
const errorMessage = `Failed for component slug: ${slug}, variant: ${variantName}`;
// Get first 2 words of the code
const firstTwoWords = code.split(" ").slice(0, 2).join(" ");
if (shouldError) {
expect(firstTwoWords, errorMessage).toEqual("An error");
} else {
expect(firstTwoWords, errorMessage).not.toEqual("An error");
}
};

for (const section of SectionsList) {
if (section.type !== "multiple-component") {
continue;
}
for (const category of section.categoriesList) {
if (category.componentList) {
for (const component of category.componentList) {
for (const variant of component.variantList) {
// Test without error
await testComponentCode(
category.slug,
`${component.slug}/${variant.slugPreviewFile}`,
false,
);

if (variant.slugComponentFile) {
await testComponentCode(
category.slug,
`${component.slug}/${variant.slugComponentFile}`,
false,
);
}

// Test with forced error
await testComponentCode(
category.slug,
`${component.slug}/${variant.slugPreviewFile}error`,
true,
);

if (variant.slugComponentFile) {
await testComponentCode(
category.slug,
`${component.slug}/${variant.slugComponentFile}error`,
true,
);
}
}
}
}
}
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { describe, expect, it } from "vitest";
import { getFileContentAsString } from "#/src/utils/get-file-content-as-string";

describe("getFileContentAsString", () => {
it("should return the content of the file", async () => {
const code = await getFileContentAsString({
componentSlug: "badges",
variantName: "modern-simple-badges/variant1",
});
it("should return the content of the file", async () => {
const code = await getFileContentAsString({
componentSlug: "badges",
variantName: "modern-simple-badges/variant1",
});

expect(code).toEqual(`export function BadgeSimpleVariantAmber() {
expect(code).toEqual(`export function BadgeSimpleVariantAmber() {
return (
<div className="inline rounded-md bg-amber-500/15 px-2 py-0.5 text-amber-500 text-sm">
Amber badge
</div>
);
}
`);
});
});
});
Loading

0 comments on commit 205f56e

Please sign in to comment.