Skip to content

Commit

Permalink
chore: update worker tests with an extra import
Browse files Browse the repository at this point in the history
  • Loading branch information
milomg committed Apr 29, 2021
1 parent 2172c99 commit ecb639b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/playground/worker/__tests__/worker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ if (isBuild) {
expect(files.length).toBe(2)
const index = files.find((f) => f.includes('index'))
const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8')
const worker = files.find((f) => f.includes('my-worker'))
const workerContent = fs.readFileSync(
path.resolve(assetsDir, worker),
'utf-8'
)

// worker should have all imports resolved and no exports
expect(workerContent).not.toMatch(`import`)
expect(workerContent).not.toMatch(`export`)
// chunk
expect(content).toMatch(`new Worker("/assets`)
// inlined
Expand Down
4 changes: 4 additions & 0 deletions packages/playground/worker/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div>Expected values: <span class="mode-true"></span></div>
<button class="ping">Ping</button>
<div>
Response from worker: <span class="pong"></span><span class="mode"></span>
Expand All @@ -9,6 +10,9 @@
<script type="module">
import Worker from './my-worker?worker'
import InlineWorker from './my-worker?worker&inline'
import { mode } from './workerImport'

document.querySelector('.mode-true').textContent = mode

const worker = new Worker()
worker.addEventListener('message', (e) => {
Expand Down

0 comments on commit ecb639b

Please sign in to comment.