Skip to content

Commit 30b6246

Browse files
committed
Add script to update tests
1 parent 6ca0342 commit 30b6246

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

test/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import plugin, { renderShadows } from '../index.js'
99

1010
const FIXTURES = join(import.meta.dirname, 'fixtures')
1111

12-
function run(input, opts) {
13-
postcss([plugin(opts)]).process(input, { from: undefined }).css
12+
export function run(input) {
13+
return postcss([plugin({})]).process(input, { from: undefined }).css
1414
}
1515

1616
let tests = readdirSync(FIXTURES).filter(i => !i.endsWith('.out.css'))

test/update-tests.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env node
2+
3+
import { readdir, readFile, writeFile } from 'node:fs/promises'
4+
import { basename, join } from 'node:path'
5+
import postcss from 'postcss'
6+
7+
import plugin from '../index.js'
8+
9+
const FIXTURES = join(import.meta.dirname, 'fixtures')
10+
11+
export function run(input) {
12+
return postcss([plugin({})]).process(input, { from: undefined }).css
13+
}
14+
15+
let tests = (await readdir(FIXTURES)).filter(i => !i.endsWith('.out.css'))
16+
await Promise.all(
17+
tests.map(async input => {
18+
await writeFile(
19+
join(FIXTURES, `${basename(input, '.css')}.out.css`),
20+
run(await readFile(join(FIXTURES, input)))
21+
)
22+
})
23+
)

0 commit comments

Comments
 (0)