Skip to content

Commit c4cfe65

Browse files
committed
chor: add test and typescript types
1 parent a9babfa commit c4cfe65

File tree

12 files changed

+190
-19
lines changed

12 files changed

+190
-19
lines changed

.github/workflows/test.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Test'
2+
on:
3+
push:
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node-version: [ 18 ]
11+
12+
permissions:
13+
# Required to check out the code
14+
contents: read
15+
# Required to put a comment into the pull-request
16+
pull-requests: write
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: pnpm/action-setup@v2
21+
with:
22+
version: 7
23+
- uses: actions/setup-node@v3
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'pnpm'
27+
- name: 'Install Deps'
28+
run: pnpm install --frozen-lockfile
29+
- name: 'Test'
30+
run: npx vitest
31+
# - name: 'Test coverage'
32+
# run: npx vitest --coverage
33+
- name: 'Report Coverage'
34+
if: always() # Also generate the report if tests are failing
35+
uses: davelosert/vitest-coverage-report-action@v2

dist/index.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
File renamed without changes.

dist/index.umd.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"designbycode"
2424
],
2525
"type": "module",
26-
"types": "dist",
26+
"types": "dist/",
2727
"main": "./dist/index.umd.cjs",
2828
"exports": {
2929
".": {
@@ -33,19 +33,18 @@
3333
},
3434
"module": "./dist/index.js",
3535
"files": [
36-
"dist",
37-
"utils"
36+
"dist"
3837
],
3938
"publishConfig": {
4039
"access": "public"
4140
},
4241
"scripts": {
43-
"build": "tsc && vite build",
42+
"build": "tsc --declaration && vite build",
4443
"clean": "rd /s /q dist .cache>nul 2>&1|echo.>nul",
4544
"dev": "pnpm build --watch",
46-
"postbuild": "tsc --emitDeclarationOnly",
4745
"prepublishOnly": "pnpm build",
48-
"release": "release-it"
46+
"release": "release-it",
47+
"test": "vitest --coverage"
4948
},
5049
"lint-staged": {
5150
"src/**/*.ts": [
@@ -79,6 +78,7 @@
7978
"@semantic-release/git": "^10.0.1",
8079
"@semantic-release/github": "^9.0.4",
8180
"@types/node": "^20.4.10",
81+
"@vitest/coverage-v8": "^0.34.1",
8282
"autoprefixer": "^10.4.14",
8383
"husky": "^8.0.3",
8484
"postcss": "^8.4.27",

pnpm-lock.yaml

Lines changed: 111 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { comment } from "postcss"
2-
import { version as packageVersion } from "../package.json"
3-
import generateShadows from "../utils/generateShadows.ts"
2+
import generateShadows from "./generateShadows"
43

4+
const version = require("../package.json")
55
const plugin = require("tailwindcss/plugin")
66
const { default: flattenColorPalette } = require("tailwindcss/lib/util/flattenColorPalette")
77

@@ -22,7 +22,7 @@ module.exports = plugin.withOptions(
2222
return function ({ addBase, addComponents, matchUtilities, matchComponents, theme }: any): void {
2323
addBase([
2424
comment({
25-
text: `! tailwindcss-text-shadow v${packageVersion} | MIT License | https://designbycode.co.za`,
25+
text: `! tailwindcss-text-shadow v${version} | MIT License | https://designbycode.co.za`,
2626
}),
2727
])
2828

test/generateShadows.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {describe, it, expect} from "vitest";
2+
import generateShadows from "../src/generateShadows";
3+
4+
5+
describe('# Generate shadow', () => {
6+
7+
const singleLine = `calc(var(--ts-text-shadow-x) * 0) calc(var(--ts-text-shadow-y) * 0) var(--ts-text-shadow-blur) var(--ts-text-shadow-color)`
8+
9+
const doubleLine = `calc(var(--ts-text-shadow-x) * 0) calc(var(--ts-text-shadow-y) * 0) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 1) calc(var(--ts-text-shadow-y) * 1) var(--ts-text-shadow-blur) var(--ts-text-shadow-color)`
10+
11+
const tenSteps = `calc(var(--ts-text-shadow-x) * 0) calc(var(--ts-text-shadow-y) * 0) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 1) calc(var(--ts-text-shadow-y) * 1) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 2) calc(var(--ts-text-shadow-y) * 2) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 3) calc(var(--ts-text-shadow-y) * 3) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 4) calc(var(--ts-text-shadow-y) * 4) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 5) calc(var(--ts-text-shadow-y) * 5) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 6) calc(var(--ts-text-shadow-y) * 6) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 7) calc(var(--ts-text-shadow-y) * 7) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 8) calc(var(--ts-text-shadow-y) * 8) var(--ts-text-shadow-blur) var(--ts-text-shadow-color),calc(var(--ts-text-shadow-x) * 9) calc(var(--ts-text-shadow-y) * 9) var(--ts-text-shadow-blur) var(--ts-text-shadow-color)`
12+
13+
it("should be 1 shadow line", () => {
14+
expect(generateShadows(1)).toEqual(singleLine)
15+
});
16+
17+
it("should be 2 shadow line", () => {
18+
expect(generateShadows(2)).toEqual(doubleLine)
19+
});
20+
21+
it("should be 10 shadow line", () => {
22+
expect(generateShadows(10)).toEqual(tenSteps)
23+
});
24+
25+
})

0 commit comments

Comments
 (0)