From 69ebdd9e9bfba3b9cb34caa4636390052d441f1e Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Mon, 7 Oct 2024 20:22:27 -0500 Subject: [PATCH 1/2] chore: add tests the `@halvaradop/tailwindcss-core` package --- package.json | 4 +-- packages/tailwindcss-core/test/index.test.ts | 32 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 packages/tailwindcss-core/test/index.test.ts diff --git a/package.json b/package.json index 727e927..8ca2343 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "build:ci": "npm run build:core && npm run build", "format": "prettier --cache --write .", "format:check": "prettier --cache --check .", - "test": "turbo test --filter=!@halvaradop/tailwindcss-core", - "test:watch": "turbo test:watch --parallel --filter=!@halvaradop/tailwindcss-core", + "test": "turbo test --parallel", + "test:watch": "turbo test:watch --parallel", "test:coverage": "vitest --coverage" }, "publishConfig": { diff --git a/packages/tailwindcss-core/test/index.test.ts b/packages/tailwindcss-core/test/index.test.ts new file mode 100644 index 0000000..076a198 --- /dev/null +++ b/packages/tailwindcss-core/test/index.test.ts @@ -0,0 +1,32 @@ +import { describe, test, expect } from "vitest" +import { extractClasses } from "../src/generate-classes" + +/** + * Provide a mock implementation of the extractClasses function with an + * empty plugin. The implementation is responsible for setting up the + * plugin. + */ +const generateClasses = extractClasses({ + config: {}, + handler: () => {} +}) + +describe("Extract classes from tailwindcss", () => { + test("Extract classes without provided HTML content", async () => { + const html = `` + const css = await generateClasses(html) + expect(css).toMatch("") + }) + + test("Extract classes with provided empty HTML content", async () => { + const html = `
` + const css = await generateClasses(html) + expect(css).toMatch("") + }) + + test("Extract classes with provided HTML content and Tailwindcss class", async () => { + const html = `
` + const css = await generateClasses(html) + expect(css).toMatch(".text-lg{font-size:1.125rem;line-height:1.75rem}") + }) +}) \ No newline at end of file From 823192bfc0034ae6be2d4f29379ed2c2d1a6afbc Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Mon, 7 Oct 2024 20:51:46 -0500 Subject: [PATCH 2/2] chore: run format --- packages/tailwindcss-core/test/index.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/tailwindcss-core/test/index.test.ts b/packages/tailwindcss-core/test/index.test.ts index 076a198..fde8b59 100644 --- a/packages/tailwindcss-core/test/index.test.ts +++ b/packages/tailwindcss-core/test/index.test.ts @@ -3,12 +3,12 @@ import { extractClasses } from "../src/generate-classes" /** * Provide a mock implementation of the extractClasses function with an - * empty plugin. The implementation is responsible for setting up the + * empty plugin. The implementation is responsible for setting up the * plugin. */ -const generateClasses = extractClasses({ - config: {}, - handler: () => {} +const generateClasses = extractClasses({ + config: {}, + handler: () => {}, }) describe("Extract classes from tailwindcss", () => { @@ -29,4 +29,4 @@ describe("Extract classes from tailwindcss", () => { const css = await generateClasses(html) expect(css).toMatch(".text-lg{font-size:1.125rem;line-height:1.75rem}") }) -}) \ No newline at end of file +})