MCPcopy
hub / github.com/vitejs/vite / sassTest

Function sassTest

playground/css/__tests__/sass-tests.ts:4–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { editFile, getBg, getColor, isBuild, page, viteTestUrl } from '~utils'
3
4export const sassTest = () => {
5 test('sass', async () => {
6 const imported = await page.$('.sass')
7 const atImport = await page.$('.sass-at-import')
8 const atImportAlias = await page.$('.sass-at-import-alias')
9 const atImportRelative = await page.$('.sass-at-import-relative')
10 const atImportReplacementAlias = await page.$(
11 '.sass-at-import-replacement-alias',
12 )
13 const urlStartsWithVariable = await page.$('.sass-url-starts-with-variable')
14 const urlStartsWithVariableInterpolation1 = await page.$(
15 '.sass-url-starts-with-interpolation1',
16 )
17 const urlStartsWithVariableInterpolation2 = await page.$(
18 '.sass-url-starts-with-interpolation2',
19 )
20 const urlStartsWithVariableConcat = await page.$(
21 '.sass-url-starts-with-variable-concat',
22 )
23 const urlStartsWithFunctionCall = await page.$(
24 '.sass-url-starts-with-function-call',
25 )
26 const partialImport = await page.$('.sass-partial')
27
28 expect(await getColor(imported)).toBe('orange')
29 expect(await getColor(atImport)).toBe('olive')
30 expect(await getBg(atImport)).toMatch(
31 isBuild ? /base64/ : '/nested/icon.png',
32 )
33 expect(await getColor(atImportAlias)).toBe('olive')
34 expect(await getBg(atImportAlias)).toMatch(
35 isBuild ? /base64/ : '/nested/icon.png',
36 )
37 expect(await getColor(atImportRelative)).toBe('olive')
38 expect(await getBg(atImportRelative)).toMatch(
39 isBuild ? /base64/ : '/nested/icon.png',
40 )
41 expect(await getColor(atImportReplacementAlias)).toBe('olive')
42 expect(await getBg(urlStartsWithVariable)).toMatch(
43 isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
44 )
45 expect(await getBg(urlStartsWithVariableInterpolation1)).toMatch(
46 isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
47 )
48 expect(await getBg(urlStartsWithVariableInterpolation2)).toMatch(
49 isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
50 )
51 expect(await getBg(urlStartsWithVariableConcat)).toMatch(
52 isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
53 )
54 expect(await getBg(urlStartsWithFunctionCall)).toMatch(
55 isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
56 )
57 expect(await getColor(partialImport)).toBe('orchid')
58 expect(await getColor(await page.$('.sass-file-absolute'))).toBe('orange')
59 expect(await getColor(await page.$('.sass-dir-index'))).toBe('orange')
60 expect(await getColor(await page.$('.sass-root-relative'))).toBe('orange')
61

Callers 1

tests.tsFile · 0.90

Calls 4

testFunction · 0.90
getColorFunction · 0.85
getBgFunction · 0.85
editFileFunction · 0.50

Tested by

no test coverage detected