| 2 | import { editFile, getBg, getColor, isBuild, page, viteTestUrl } from class="st">'~utils' |
| 3 | |
| 4 | export const sassTest = () => { |
| 5 | test(class="st">'sass', async () => { |
| 6 | const imported = await page.$(class="st">'.sass') |
| 7 | const atImport = await page.$(class="st">'.sass-at-import') |
| 8 | const atImportAlias = await page.$(class="st">'.sass-at-import-alias') |
| 9 | const atImportRelative = await page.$(class="st">'.sass-at-import-relative') |
| 10 | const atImportReplacementAlias = await page.$( |
| 11 | class="st">'.sass-at-import-replacement-alias', |
| 12 | ) |
| 13 | const urlStartsWithVariable = await page.$(class="st">'.sass-url-starts-with-variable') |
| 14 | const urlStartsWithVariableInterpolation1 = await page.$( |
| 15 | class="st">'.sass-url-starts-with-interpolation1', |
| 16 | ) |
| 17 | const urlStartsWithVariableInterpolation2 = await page.$( |
| 18 | class="st">'.sass-url-starts-with-interpolation2', |
| 19 | ) |
| 20 | const urlStartsWithVariableConcat = await page.$( |
| 21 | class="st">'.sass-url-starts-with-variable-concat', |
| 22 | ) |
| 23 | const urlStartsWithFunctionCall = await page.$( |
| 24 | class="st">'.sass-url-starts-with-function-call', |
| 25 | ) |
| 26 | const partialImport = await page.$(class="st">'.sass-partial') |
| 27 | |
| 28 | expect(await getColor(imported)).toBe(class="st">'orange') |
| 29 | expect(await getColor(atImport)).toBe(class="st">'olive') |
| 30 | expect(await getBg(atImport)).toMatch( |
| 31 | isBuild ? /base64/ : class="st">'/nested/icon.png', |
| 32 | ) |
| 33 | expect(await getColor(atImportAlias)).toBe(class="st">'olive') |
| 34 | expect(await getBg(atImportAlias)).toMatch( |
| 35 | isBuild ? /base64/ : class="st">'/nested/icon.png', |
| 36 | ) |
| 37 | expect(await getColor(atImportRelative)).toBe(class="st">'olive') |
| 38 | expect(await getBg(atImportRelative)).toMatch( |
| 39 | isBuild ? /base64/ : class="st">'/nested/icon.png', |
| 40 | ) |
| 41 | expect(await getColor(atImportReplacementAlias)).toBe(class="st">'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(class="st">'orchid') |
| 58 | expect(await getColor(await page.$(class="st">'.sass-file-absolute'))).toBe(class="st">'orange') |
| 59 | expect(await getColor(await page.$(class="st">'.sass-dir-index'))).toBe(class="st">'orange') |
| 60 | expect(await getColor(await page.$(class="st">'.sass-root-relative'))).toBe(class="st">'orange') |
| 61 | |