generated from sonofmagic/monorepo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.test.ts
32 lines (27 loc) · 899 Bytes
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { internalPatch } from '../src/patcher'
import path from 'path'
const tailwindcssCasePath = path.resolve(__dirname, 'fixtures')
const versionsPkgDir = path.resolve(tailwindcssCasePath, 'versions/package.json')
function getTailwindcssVersion(str: string) {
// eslint-disable-next-line no-useless-escape
const match = /^tailwindcss([\d\.]*)$/.exec(str)
if (match === null) {
// 不是 tailwindcss
return false
} else if (match[1] === '') {
return 'lts'
} else {
return match[1]
}
}
const pkg = require(versionsPkgDir)
const versions = Object.keys(pkg.dependencies)
describe('versions-patch', () => {
it.each(versions)('patch %s', (version) => {
const v = getTailwindcssVersion(version)
const res = internalPatch(path.resolve(tailwindcssCasePath, `versions/${v}/package.json`), {
overwrite: false
})
expect(res).toMatchSnapshot()
})
})