generated from sonofmagic/monorepo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcontext.test.ts
35 lines (33 loc) · 1.18 KB
/
context.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
33
34
35
import { getContexts, getClassCacheSet } from '../src'
import { getCss, getTestCase } from './utils'
describe('common usage', () => {
it('hello-world', () => {
const result = getCss(getTestCase('hello-world.html'))
const ctxs = getContexts()
expect(ctxs.length).toBeTruthy()
const set = getClassCacheSet()
expect(set.size).toBeGreaterThan(0)
expect(set.size).toBe(4)
expect(result).toMatchSnapshot()
})
it('hello-world with js', () => {
const result = getCss([getTestCase('hello-world.html'), getTestCase('hello-world.js')])
const ctxs = getContexts()
expect(ctxs.length).toBeTruthy()
const set = getClassCacheSet()
expect(set.size).toBeGreaterThan(0)
expect(set.size).toBe(5)
expect(result).toMatchSnapshot()
})
// https://github.com/sonofmagic/weapp-tailwindcss-webpack-plugin/issues/158
it("bg-[url('img_src')] lose efficacy", () => {
getCss([getTestCase('img-url.jsx')])
const ctxs = getContexts()
expect(ctxs).toBeTruthy()
const set = getClassCacheSet()
expect(set.size).toBeGreaterThan(0)
expect(set.size).toBe(2)
expect(Array.from(set.values())[1]).toBe("bg-[url('https://xxx.webp')]")
//
})
})