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 d8c2fe1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
21 changes: 15 additions & 6 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,18 @@ 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:application/javascript;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.

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

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

.url {
color:green;
}

.raw {
&{
color:green;
}
}

0 comments on commit d8c2fe1

Please sign in to comment.