Skip to content

Commit

Permalink
test: for special query
Browse files Browse the repository at this point in the history
  • Loading branch information
CHOYSEN committed Oct 8, 2021
1 parent 41b0fdf commit c37f16f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 13 deletions.
21 changes: 16 additions & 5 deletions packages/playground/css/__tests__/css.spec.ts
@@ -1,13 +1,11 @@
import fs from 'fs'
import path from 'path'
import {
editFile,
findAssetFile,
getBg,
getColor,
isBuild,
removeFile,
testDir,
readFile,
untilUpdated
} from '../../testUtils'

Expand Down Expand Up @@ -334,7 +332,20 @@ test('Url separation', async () => {
}
})

test('inlined', async () => {
test('special query', async () => {
// should not insert css
expect(await getColor('.inlined')).toBe('black')
expect(await getColor('.url')).toBe('black')
expect(await getColor('.raw')).toBe('black')
expect(await getColor('.inline')).toBe('black')

const source = readFile('special-query.scss')

expect(await page.textContent('.url')).toMatch(
isBuild
? `data:null;base64,${Buffer.from(source).toString(
'base64'
)}`
: '/special-query.scss'
)
expect(await page.textContent('.raw')).toMatch(source)
})
10 changes: 8 additions & 2 deletions packages/playground/css/index.html
Expand Up @@ -102,8 +102,14 @@ <h1>CSS</h1>
Url separation preservation: should have valid background-image
</p>

<p class="inlined">Inlined import - this should NOT be red.</p>
<pre class="inlined-code"></pre>
<p class="url">?url import - this should NOT be green</p>
<pre class="url-code"></pre>

<p class="raw">?raw import - this should NOT be green</p>
<pre class="raw-code"></pre>

<p class="inline">?inline import - this should NOT be green</p>
<pre class="inline-code"></pre>
</div>

<script type="module" src="./main.js"></script>
3 changes: 0 additions & 3 deletions packages/playground/css/inlined.css

This file was deleted.

14 changes: 11 additions & 3 deletions packages/playground/css/main.js
Expand Up @@ -63,6 +63,14 @@ if (import.meta.env.DEV) {
import('./async-treeshaken')
}

// inlined
import inlined from './inlined.css?inline'
text('.inlined-code', inlined)
// ?url import
import url from './special-query.scss?url'
text('.url-code', url)

// ?raw import
import raw from './special-query.scss?raw'
text('.raw-code', raw)

// ?inline import
import inline from './special-query.scss?inline'
text('.inline-code', inline)
13 changes: 13 additions & 0 deletions packages/playground/css/special-query.scss
@@ -0,0 +1,13 @@
.inline {
color: green;
}

.url {
color: green;
}

.raw {
& {
color: green;
}
}

0 comments on commit c37f16f

Please sign in to comment.