test: add unit tests for the module (#892)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Juho Rutila
2023-11-02 12:00:20 +02:00
committed by GitHub
parent a2d70f04e9
commit ed4b5e0077
7 changed files with 420 additions and 13 deletions

View File

@@ -74,6 +74,9 @@ jobs:
- name: Build
run: pnpm run build
- name: Test
run: pnpm run test run
- name: Release Edge
if: github.event_name == 'push' && steps.changes.outputs.src == 'true'
run: ./scripts/release-edge.sh

View File

@@ -58,6 +58,9 @@ jobs:
- name: Build
run: pnpm run build
- name: Test
run: pnpm run test run
- name: Version Check
id: check
uses: EndBug/version-check@v2

View File

@@ -27,7 +27,8 @@
"lint:fix": "eslint . --fix",
"typecheck": "vue-tsc --noEmit && nuxi typecheck docs",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare docs",
"release": "release-it"
"release": "release-it",
"test": "vitest"
},
"dependencies": {
"@egoist/tailwindcss-icons": "^1.4.0",
@@ -64,6 +65,7 @@
"typescript": "^5.2.2",
"unbuild": "^2.0.0",
"valibot": "^0.19.0",
"vitest": "^0.34.6",
"vue-tsc": "^1.8.21",
"yup": "^1.3.2",
"zod": "^3.22.4"

282
pnpm-lock.yaml generated
View File

@@ -105,6 +105,9 @@ importers:
valibot:
specifier: ^0.19.0
version: 0.19.0
vitest:
specifier: ^0.34.6
version: 0.34.6
vue-tsc:
specifier: ^1.8.21
version: 1.8.21(typescript@5.2.2)
@@ -1338,6 +1341,13 @@ packages:
wrap-ansi-cjs: /wrap-ansi@7.0.0
dev: true
/@jest/schemas@29.6.3:
resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
'@sinclair/typebox': 0.27.8
dev: true
/@jridgewell/gen-mapping@0.3.3:
resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==}
engines: {node: '>=6.0.0'}
@@ -1588,7 +1598,7 @@ packages:
'@nuxt/schema': 3.8.0(rollup@3.29.1)
execa: 7.2.0
nuxt: 3.8.0(eslint@8.52.0)(rollup@3.29.1)(typescript@5.2.2)(vite@4.5.0)(vue-tsc@1.8.21)
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
transitivePeerDependencies:
- rollup
- supports-color
@@ -1652,7 +1662,7 @@ packages:
simple-git: 3.20.0
sirv: 2.0.3
unimport: 3.4.0(rollup@3.29.1)
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
vite-plugin-inspect: 0.7.40(@nuxt/kit@3.8.0)(rollup@3.29.1)(vite@4.5.0)
vite-plugin-vue-inspector: 4.0.0(vite@4.5.0)
which: 3.0.1
@@ -1828,7 +1838,7 @@ packages:
consola: 3.2.3
create-require: 1.1.1
defu: 6.1.3
destr: 2.0.1
destr: 2.0.2
dotenv: 16.3.1
git-url-parse: 13.1.0
is-docker: 3.0.0
@@ -1961,7 +1971,7 @@ packages:
strip-literal: 1.3.0
ufo: 1.3.1
unplugin: 1.5.0
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
vite-node: 0.33.0
vite-plugin-checker: 0.6.2(eslint@8.52.0)(typescript@5.2.2)(vite@4.5.0)(vue-tsc@1.8.21)
vue: 3.3.4
@@ -2896,6 +2906,10 @@ packages:
- supports-color
dev: true
/@sinclair/typebox@0.27.8:
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
dev: true
/@sindresorhus/is@3.1.2:
resolution: {integrity: sha512-JiX9vxoKMmu8Y3Zr2RVathBL1Cdu4Nt4MuNWemt1Nc06A0RAin9c5FArkhGsyMBWfCu4zj+9b+GxtjAnE4qqLQ==}
engines: {node: '>=10'}
@@ -2990,6 +3004,16 @@ packages:
minimatch: 9.0.3
dev: true
/@types/chai-subset@1.3.4:
resolution: {integrity: sha512-CCWNXrJYSUIojZ1149ksLl3AN9cmZ5djf+yUoVVV+NuYrtydItQVlL2ZDqyC6M6O9LWRnVf8yYDxbXHO2TfQZg==}
dependencies:
'@types/chai': 4.3.9
dev: true
/@types/chai@4.3.9:
resolution: {integrity: sha512-69TtiDzu0bcmKQv3yg1Zx409/Kd7r0b5F1PfpYJfSHzLGtB53547V4u+9iqKYsTu/O2ai6KTb0TInNpvuQ3qmg==}
dev: true
/@types/debug@4.1.8:
resolution: {integrity: sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ==}
dependencies:
@@ -3311,7 +3335,7 @@ packages:
'@babel/core': 7.23.0
'@babel/plugin-transform-typescript': 7.22.15(@babel/core@7.23.0)
'@vue/babel-plugin-jsx': 1.1.5(@babel/core@7.23.0)
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
vue: 3.3.4
transitivePeerDependencies:
- supports-color
@@ -3324,10 +3348,48 @@ packages:
vite: ^4.0.0
vue: ^3.2.25
dependencies:
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
vue: 3.3.4
dev: true
/@vitest/expect@0.34.6:
resolution: {integrity: sha512-QUzKpUQRc1qC7qdGo7rMK3AkETI7w18gTCUrsNnyjjJKYiuUB9+TQK3QnR1unhCnWRC0AbKv2omLGQDF/mIjOw==}
dependencies:
'@vitest/spy': 0.34.6
'@vitest/utils': 0.34.6
chai: 4.3.10
dev: true
/@vitest/runner@0.34.6:
resolution: {integrity: sha512-1CUQgtJSLF47NnhN+F9X2ycxUP0kLHQ/JWvNHbeBfwW8CzEGgeskzNnHDyv1ieKTltuR6sdIHV+nmR6kPxQqzQ==}
dependencies:
'@vitest/utils': 0.34.6
p-limit: 4.0.0
pathe: 1.1.1
dev: true
/@vitest/snapshot@0.34.6:
resolution: {integrity: sha512-B3OZqYn6k4VaN011D+ve+AA4whM4QkcwcrwaKwAbyyvS/NB1hCWjFIBQxAQQSQir9/RtyAAGuq+4RJmbn2dH4w==}
dependencies:
magic-string: 0.30.5
pathe: 1.1.1
pretty-format: 29.7.0
dev: true
/@vitest/spy@0.34.6:
resolution: {integrity: sha512-xaCvneSaeBw/cz8ySmF7ZwGvL0lBjfvqc1LpQ/vcdHEvpLn3Ff1vAvjw+CoGn0802l++5L/pxb7whwcWAw+DUQ==}
dependencies:
tinyspy: 2.2.0
dev: true
/@vitest/utils@0.34.6:
resolution: {integrity: sha512-IG5aDD8S6zlvloDsnzHw0Ut5xczlF+kv2BOTo+iXfPr54Yhi5qbVOgGB1hZaVq4iJ4C/MZ2J0y15IlsV/ZcI0A==}
dependencies:
diff-sequences: 29.6.3
loupe: 2.3.7
pretty-format: 29.7.0
dev: true
/@volar/language-core@1.10.1:
resolution: {integrity: sha512-JnsM1mIPdfGPxmoOcK1c7HYAsL6YOv0TCJ4aW3AXPZN/Jb4R77epDyMZIVudSGjWMbvv/JfUa+rQ+dGKTmgwBA==}
dependencies:
@@ -3763,6 +3825,11 @@ packages:
acorn: 8.10.0
dev: true
/acorn-walk@8.3.0:
resolution: {integrity: sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==}
engines: {node: '>=0.4.0'}
dev: true
/acorn@8.10.0:
resolution: {integrity: sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==}
engines: {node: '>=0.4.0'}
@@ -3858,6 +3925,11 @@ packages:
dependencies:
color-convert: 2.0.1
/ansi-styles@5.2.0:
resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==}
engines: {node: '>=10'}
dev: true
/ansi-styles@6.2.1:
resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==}
engines: {node: '>=12'}
@@ -3968,6 +4040,10 @@ packages:
is-shared-array-buffer: 1.0.2
dev: true
/assertion-error@1.1.0:
resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
dev: true
/ast-kit@0.11.2(rollup@3.29.1):
resolution: {integrity: sha512-Q0DjXK4ApbVoIf9GLyCo252tUH44iTnD/hiJ2TQaJeydYWSpKk0sI34+WMel8S9Wt5pbLgG02oJ+gkgX5DV3sQ==}
engines: {node: '>=16.14.0'}
@@ -4354,6 +4430,19 @@ packages:
resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
dev: true
/chai@4.3.10:
resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==}
engines: {node: '>=4'}
dependencies:
assertion-error: 1.1.0
check-error: 1.0.3
deep-eql: 4.1.3
get-func-name: 2.0.2
loupe: 2.3.7
pathval: 1.1.1
type-detect: 4.0.8
dev: true
/chalk@2.4.2:
resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==}
engines: {node: '>=4'}
@@ -4399,6 +4488,12 @@ packages:
resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==}
dev: true
/check-error@1.0.3:
resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==}
dependencies:
get-func-name: 2.0.2
dev: true
/chokidar@3.5.3:
resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
engines: {node: '>= 8.10.0'}
@@ -5107,6 +5202,13 @@ packages:
mimic-response: 3.1.0
dev: true
/deep-eql@4.1.3:
resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==}
engines: {node: '>=6'}
dependencies:
type-detect: 4.0.8
dev: true
/deep-equal@1.0.1:
resolution: {integrity: sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==}
@@ -5257,6 +5359,11 @@ packages:
/didyoumean@1.2.2:
resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==}
/diff-sequences@29.6.3:
resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dev: true
/diff@5.1.0:
resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==}
engines: {node: '>=0.3.1'}
@@ -6149,6 +6256,10 @@ packages:
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
engines: {node: 6.* || 8.* || >= 10.*}
/get-func-name@2.0.2:
resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==}
dev: true
/get-intrinsic@1.2.1:
resolution: {integrity: sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==}
dependencies:
@@ -7720,6 +7831,12 @@ packages:
resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
dev: true
/loupe@2.3.7:
resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==}
dependencies:
get-func-name: 2.0.2
dev: true
/lowercase-keys@3.0.0:
resolution: {integrity: sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
@@ -7755,7 +7872,7 @@ packages:
resolution: {integrity: sha512-C9m5/JqFV1/CMrMFDf1PqmvMc8ohrssmlF5bdgea7nUqqn6D9xzKVTa6DIm0LReCqvEPS35o1UElmb7PmoSfHQ==}
dependencies:
estree-walker: 3.0.3
magic-string: 0.30.3
magic-string: 0.30.5
mlly: 1.4.2
type-level-regexp: 0.1.17
ufo: 1.3.1
@@ -9717,6 +9834,10 @@ packages:
/pathe@1.1.1:
resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==}
/pathval@1.1.1:
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
dev: true
/pause-stream@0.0.11:
resolution: {integrity: sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A==}
dependencies:
@@ -10239,6 +10360,15 @@ packages:
engines: {node: ^14.13.1 || >=16.0.0}
dev: true
/pretty-format@29.7.0:
resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies:
'@jest/schemas': 29.6.3
ansi-styles: 5.2.0
react-is: 18.2.0
dev: true
/proc-log@3.0.0:
resolution: {integrity: sha512-++Vn7NS4Xf9NacaU9Xq3URUuqZETPsf8L4j5/ckhaRYsfPeRyzGw+iDjFhV/Jr3uNmTvvddEJFWh5R1gRgUH8A==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
@@ -10390,6 +10520,10 @@ packages:
strip-json-comments: 2.0.1
dev: true
/react-is@18.2.0:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
dev: true
/read-cache@1.0.0:
resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==}
dependencies:
@@ -11012,6 +11146,10 @@ packages:
object-inspect: 1.12.3
dev: true
/siginfo@2.0.0:
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
dev: true
/signal-exit@3.0.7:
resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
@@ -11211,6 +11349,10 @@ packages:
minipass: 7.0.3
dev: true
/stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
dev: true
/standard-as-callback@2.1.0:
resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==}
dev: true
@@ -11596,6 +11738,20 @@ packages:
resolution: {integrity: sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==}
dev: true
/tinybench@2.5.1:
resolution: {integrity: sha512-65NKvSuAVDP/n4CqH+a9w2kTlLReS9vhsAP06MWx+/89nMinJyB2icyl58RIcqCmIggpojIGeuJGhjU1aGMBSg==}
dev: true
/tinypool@0.7.0:
resolution: {integrity: sha512-zSYNUlYSMhJ6Zdou4cJwo/p7w5nmAH17GRfU/ui3ctvjXFErXXkruT4MWW6poDeXgCaIBlGLrfU6TbTXxyGMww==}
engines: {node: '>=14.0.0'}
dev: true
/tinyspy@2.2.0:
resolution: {integrity: sha512-d2eda04AN/cPOR89F7Xv5bK/jrQEhmcLFe6HFldoeO9AJtps+fqEnh486vnT/8y4bw38pSyxDcTCAq+Ks2aJTg==}
engines: {node: '>=14.0.0'}
dev: true
/tinyws@0.1.0(ws@8.14.2):
resolution: {integrity: sha512-6WQ2FlFM7qm6lAXxeKnzsAEfmnBHz5W5EwonNs52V0++YfK1IoCCAWM429afcChFE9BFrDgOFnq7ligaWMsa/A==}
engines: {node: '>=12.4'}
@@ -11703,6 +11859,11 @@ packages:
prelude-ls: 1.2.1
dev: true
/type-detect@4.0.8:
resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==}
engines: {node: '>=4'}
dev: true
/type-fest@0.20.2:
resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==}
engines: {node: '>=10'}
@@ -12360,7 +12521,29 @@ packages:
mlly: 1.4.2
pathe: 1.1.1
picocolors: 1.0.0
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
transitivePeerDependencies:
- '@types/node'
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
dev: true
/vite-node@0.34.6(@types/node@20.6.3):
resolution: {integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==}
engines: {node: '>=v14.18.0'}
hasBin: true
dependencies:
cac: 6.7.14
debug: 4.3.4
mlly: 1.4.2
pathe: 1.1.1
picocolors: 1.0.0
vite: 4.5.0(@types/node@20.6.3)
transitivePeerDependencies:
- '@types/node'
- less
@@ -12418,7 +12601,7 @@ packages:
strip-ansi: 6.0.1
tiny-invariant: 1.3.1
typescript: 5.2.2
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
vscode-languageclient: 7.0.0
vscode-languageserver: 7.0.0
vscode-languageserver-textdocument: 1.0.8
@@ -12445,7 +12628,7 @@ packages:
open: 9.1.0
picocolors: 1.0.0
sirv: 2.0.3
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
transitivePeerDependencies:
- rollup
- supports-color
@@ -12465,12 +12648,12 @@ packages:
'@vue/compiler-dom': 3.3.4
kolorist: 1.8.0
magic-string: 0.30.5
vite: 4.5.0
vite: 4.5.0(@types/node@20.6.3)
transitivePeerDependencies:
- supports-color
dev: true
/vite@4.5.0:
/vite@4.5.0(@types/node@20.6.3):
resolution: {integrity: sha512-ulr8rNLA6rkyFAlVWw2q5YJ91v098AFQ2R0PRFwPzREXOUJQPtFUG0t+/ZikhaOCDqFoDhN6/v8Sq0o4araFAw==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
@@ -12498,6 +12681,7 @@ packages:
terser:
optional: true
dependencies:
'@types/node': 20.6.3
esbuild: 0.18.20
postcss: 8.4.31
rollup: 3.29.1
@@ -12505,6 +12689,71 @@ packages:
fsevents: 2.3.3
dev: true
/vitest@0.34.6:
resolution: {integrity: sha512-+5CALsOvbNKnS+ZHMXtuUC7nL8/7F1F2DnHGjSsszX8zCjWSSviphCb/NuS9Nzf4Q03KyyDRBAXhF/8lffME4Q==}
engines: {node: '>=v14.18.0'}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@vitest/browser': '*'
'@vitest/ui': '*'
happy-dom: '*'
jsdom: '*'
playwright: '*'
safaridriver: '*'
webdriverio: '*'
peerDependenciesMeta:
'@edge-runtime/vm':
optional: true
'@vitest/browser':
optional: true
'@vitest/ui':
optional: true
happy-dom:
optional: true
jsdom:
optional: true
playwright:
optional: true
safaridriver:
optional: true
webdriverio:
optional: true
dependencies:
'@types/chai': 4.3.9
'@types/chai-subset': 1.3.4
'@types/node': 20.6.3
'@vitest/expect': 0.34.6
'@vitest/runner': 0.34.6
'@vitest/snapshot': 0.34.6
'@vitest/spy': 0.34.6
'@vitest/utils': 0.34.6
acorn: 8.10.0
acorn-walk: 8.3.0
cac: 6.7.14
chai: 4.3.10
debug: 4.3.4
local-pkg: 0.4.3
magic-string: 0.30.5
pathe: 1.1.1
picocolors: 1.0.0
std-env: 3.4.3
strip-literal: 1.3.0
tinybench: 2.5.1
tinypool: 0.7.0
vite: 4.5.0(@types/node@20.6.3)
vite-node: 0.34.6(@types/node@20.6.3)
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
dev: true
/vscode-jsonrpc@6.0.0:
resolution: {integrity: sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==}
engines: {node: '>=8.0.0 || >=10.0.0'}
@@ -12774,6 +13023,15 @@ packages:
isexe: 3.1.1
dev: true
/why-is-node-running@2.2.2:
resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==}
engines: {node: '>=8'}
hasBin: true
dependencies:
siginfo: 2.0.0
stackback: 0.0.2
dev: true
/wide-align@1.1.5:
resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==}
dependencies:

123
test/basic.spec.ts Normal file
View File

@@ -0,0 +1,123 @@
import { describe, expect, it } from 'vitest'
import module from '../src/module'
import { loadNuxt } from '@nuxt/kit'
import { join } from 'path'
// TODO: fix these anys
async function getTailwindCSSConfig (overrides: any = {}): Promise<[any, any]> {
overrides.modules = [ module ]
overrides.ssr = overrides.ssr ?? false
overrides.hooks = overrides.hooks ?? {}
return new Promise((resolve) => {
overrides.hooks['tailwindcss:resolvedConfig'] = async (config) => {
resolve([config, nuxt])
}
const nuxt = loadNuxt({
cwd: join(process.cwd(), 'fixtures', 'empty'),
dev: false,
overrides
})
})
}
describe('nuxt', () => {
it('should add plugins and modules to nuxt', async () => {
const [, lnuxt] = await getTailwindCSSConfig()
await lnuxt.then((nuxt) => {
expect(nuxt.options.plugins).toContainEqual(
expect.objectContaining({
src: expect.stringContaining('plugins/colors'),
mode: 'all'
})
)
expect(nuxt.options._requiredModules).toContain({
'@nuxtjs/color-mode': true,
'@nuxtjs/tailwindcss': true
})
// default values in appConfig
expect(nuxt.options.appConfig.ui).toContain({
primary: 'green',
gray: 'cool'
})
// TODO: this should be done inside getTailwindCSSConfig
nuxt.close()
})
})
})
describe('tailwindcss config', () => {
it.each([
/* format:
name,
tailwindcss config, safelistColors,
expected safelistPatterns (add "!" before a pattern to negate it)
*/
[
'default safelist',
{}, [],
['bg-(primary)-50', 'bg-(red)-500'] // these both should be in the safelist
],
[
'safelisting single new color',
{}, ['myColor'],
'bg-(myColor|primary)-50'
],
[
'reducing amount of theme colors',
{ theme: { colors: { plainBlue: '#00F' } } }, ['plainBlue'],
['bg-(plainBlue|primary)-50', '!', /orange/] // the word "orange" should _not_ be found in any safelist pattern
]
])('%s', async (_description, tailwindcss, safelistColors, safelistPatterns) => {
const [config, _nuxt] = await getTailwindCSSConfig({
ui: {
safelistColors
},
tailwindcss: {
config: tailwindcss
}
})
expect.extend({
toBeRegExp: (received, expected) => {
if (typeof expected === 'string' || expected instanceof String) {
return {
message: () => `expected ${received} to be exact regex ${expected}`,
pass: received.toString() === RegExp(expected as string).toString()
}
} else if (expected instanceof RegExp) {
return {
message: () => `expected ${received} to be a regex like ${expected.toString()}`,
pass: received.toString().match(expected)
}
}
return {
message: () => `expected ${received} to be a regex`,
pass: false
}
}
})
safelistPatterns = safelistPatterns instanceof Array ? safelistPatterns : [safelistPatterns]
let negate = false
for (const safelistPattern of safelistPatterns) {
if (safelistPattern === '!') {
// negate next!
negate = true
continue
}
if (negate) {
expect(config.safelist).not.toContainEqual({
pattern: expect.toBeRegExp(safelistPattern)
})
} else {
expect(config.safelist).toContainEqual({
pattern: expect.toBeRegExp(safelistPattern)
})
}
negate = false
}
await _nuxt.then((n) => {
n.close()
})
})
})

10
test/vitest.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
import type { Assertion, AsymmetricMatchersContaining } from 'vitest'
interface CustomMatchers<R = unknown> {
toBeRegExp(expected: string | RegExp): R
}
declare module 'vitest' {
interface Assertion<T = any> extends CustomMatchers<T> {}
interface AsymmetricMatchersContaining extends CustomMatchers {}
}

8
vitest.config.ts Normal file
View File

@@ -0,0 +1,8 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite'
export default defineConfig({
test: {
testTimeout: 20000
}
})