Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add tests the @halvaradop/tailwindcss-core package #78

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
32 changes: 32 additions & 0 deletions packages/tailwindcss-core/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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 = `<div class=""></div>`
const css = await generateClasses(html)
expect(css).toMatch("")
})

test("Extract classes with provided HTML content and Tailwindcss class", async () => {
const html = `<div class="text-lg"></div>`
const css = await generateClasses(html)
expect(css).toMatch(".text-lg{font-size:1.125rem;line-height:1.75rem}")
})
})