Skip to content

Commit

Permalink
chore: untilUpdated
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Aug 2, 2022
1 parent aa1fdda commit d73ff07
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
22 changes: 10 additions & 12 deletions playground/legacy/__tests__/legacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ import {
untilUpdated
} from '~utils'

test('should work', async () => {
expect(await page.textContent('#app')).toMatch('Hello')
test('should load the worker', async () => {
await untilUpdated(() => page.textContent('.worker-message'), 'module')
})

test('import.meta.env.LEGACY', async () => {
expect(await page.textContent('#env')).toMatch(isBuild ? 'true' : 'false')
test('should work', async () => {
await untilUpdated(() => page.textContent('#app'), 'Hello')
})

test('should load the worker', async () => {
expect(await page.textContent('.worker-message')).toMatchInlineSnapshot(
'"\\"module\\""'
)
test('import.meta.env.LEGACY', async () => {
await untilUpdated(() => page.textContent('#env'), isBuild ? 'true' : 'false')
})

// https://github.com/vitejs/vite/issues/3400
test('transpiles down iterators correctly', async () => {
expect(await page.textContent('#iterators')).toMatch('hello')
await untilUpdated(() => page.textContent('#iterators'), 'hello')
})

test('wraps with iife', async () => {
expect(await page.textContent('#babel-helpers')).toMatch(
await untilUpdated(
() => page.textContent('#babel-helpers'),
'exposed babel helpers: false'
)
})
Expand All @@ -54,8 +53,7 @@ test('generates assets', async () => {
'immutable-chunk: 404',
'immutable-chunk-legacy: 404',
'polyfills-legacy: 404'
].join('\n'),
true
].join('\n')
)
})

Expand Down
1 change: 1 addition & 0 deletions playground/legacy/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function text(el, text) {
}

const worker = new MyWorker()
worker.postMessage('ping')
worker.addEventListener('message', (ev) => {
text('.worker-message', JSON.stringify(ev.data))
})
4 changes: 3 additions & 1 deletion playground/legacy/worker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { module } from './module'

self.postMessage(module)
self.onmessage = () => {
self.postMessage(module)
}

0 comments on commit d73ff07

Please sign in to comment.