Skip to content

Commit

Permalink
Move tests from uvu to node --test
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Feb 10, 2024
1 parent 1cb597c commit 271c234
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 60 deletions.
30 changes: 14 additions & 16 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let { equal } = require('uvu/assert')
let { test } = require('uvu')
let { equal } = require('node:assert')
let { test } = require('node:test')
let postcss = require('postcss')

let plugin = require('./')
Expand Down Expand Up @@ -519,24 +519,24 @@ rgb(30 144 255))

test('changes root selectors for light-dark()', () => {
run(
`html, .s { --bg: light-dark(white, black) }
p { color: light-dark(red, blue) }
`html, .s {--bg: light-dark(white, black)}
p {color: light-dark(red, blue)}
`,
`@media (prefers-color-scheme:dark) {
html:where(:not(.is-light)), .s:where(:not(.is-light)) {
--bg: black
--bg: black
}
}
html:where(.is-dark), .s:where(.is-dark) {
--bg: black
--bg: black
}
@media (prefers-color-scheme:light) {
html:where(:not(.is-dark)), .s:where(:not(.is-dark)) {
--bg: white
--bg: white
}
}
html:where(.is-light), .s:where(.is-light) {
--bg: white
--bg: white
}
@media (prefers-color-scheme:dark) {
:where(html:not(.is-light)) p,:where(.s:not(.is-light)) p {
Expand All @@ -561,24 +561,24 @@ html:where(.is-light), .s:where(.is-light) {

test('changes root selector for light-dark()', () => {
run(
`body { --bg: light-dark(white, black) }
p { color: light-dark(green, yellow) }
`body {--bg: light-dark(white, black)}
p {color: light-dark(green, yellow)}
`,
`@media (prefers-color-scheme:dark) {
body:where(:not(.is-light)) {
--bg: black
--bg: black
}
}
body:where(.is-dark) {
--bg: black
--bg: black
}
@media (prefers-color-scheme:light) {
body:where(:not(.is-dark)) {
--bg: white
--bg: white
}
}
body:where(.is-light) {
--bg: white
--bg: white
}
@media (prefers-color-scheme:dark) {
:where(body:not(.is-light)) p {
Expand All @@ -600,5 +600,3 @@ body:where(.is-light) {
{ rootSelector: 'body' }
)
})

test.run()
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"theme-switcher"
],
"scripts": {
"unit": "uvu . '\\.test\\.js$'",
"unit": "node --test index.test.js",
"test:coverage": "c8 pnpm unit",
"test:lint": "eslint .",
"test": "pnpm run /^test:/"
Expand Down Expand Up @@ -49,8 +49,7 @@
"eslint-plugin-perfectionist": "^2.5.0",
"eslint-plugin-prefer-let": "^3.0.1",
"eslint-plugin-promise": "^6.1.1",
"postcss": "^8.4.35",
"uvu": "^0.5.6"
"postcss": "^8.4.35"
},
"prettier": {
"arrowParens": "avoid",
Expand Down
41 changes: 0 additions & 41 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 271c234

Please sign in to comment.