Skip to content

Commit

Permalink
feat: test
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Apr 21, 2022
1 parent fc37bdc commit 0d556c6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,27 @@ test('should load dynamic import with css', async () => {
true
)
})

test('should load dynamic import with vars', async () => {
await untilUpdated(
() => page.textContent('.dynamic-import-with-vars'),
'hello',
true
)
})

test('should load dynamic import with vars alias', async () => {
await untilUpdated(
() => page.textContent('.dynamic-import-with-vars-alias'),
'hello',
true
)
})

test('should load dynamic import with vars raw', async () => {
await untilUpdated(
() => page.textContent('.dynamic-import-with-vars-raw'),
'export function hello()',
true
)
})
14 changes: 14 additions & 0 deletions packages/playground/dynamic-import/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
<button class="issue-2658-2">Issue 2658 - 2</button>
<button class="css">css</button>

<p>dynamic-import-with-vars</p>
<div class="dynamic-import-with-vars">todo</div>

<p>dynamic-import-with-vars-alias</p>
<div class="dynamic-import-with-vars-alias">todo</div>

<p>dynamic-import-with-vars-raw</p>
<div class="dynamic-import-with-vars-raw">todo</div>

<div class="view"></div>

<script type="module" src="./nested/index.js"></script>
<style>
p {
color: #0088ff;
}
</style>
9 changes: 3 additions & 6 deletions packages/playground/dynamic-import/nested/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,13 @@ function text(el, text) {
const base = 'hello'

import(`../alias/${base}.js`).then((mod) => {
console.log('dynamic-import-with-vars', mod)
text('.dynamic-import-with-vars', mod.hello())
})

import(`@/${base}.js`).then((mod) => {
console.log('dynamic-import-with-vars-alias', mod)
text('.dynamic-import-with-vars-alias', mod.hello())
})

import(`../alias/${base}.js?raw`).then((mod) => {
console.log('dynamic-import-with-vars-?raw', mod)
text('.dynamic-import-with-vars-raw', JSON.stringify(mod))
})

const glob = import.meta.glob(`../alias/*.js`, { as: 'raw' })
console.log('dynamic-import-import.meta.glob-vars', glob)

0 comments on commit 0d556c6

Please sign in to comment.