Skip to content

Commit

Permalink
Add tree-shaking test with eval
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Nov 4, 2021
1 parent 0f0bebc commit c43d311
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test/integration/middleware/core/lib/utils.js
@@ -0,0 +1,8 @@
export function getTextWithEval() {
// eslint-disable-next-line no-eval
return eval('with some text')
}

export function getText() {
return 'with some text'
}
@@ -1,6 +1,7 @@
import { createElement } from 'react'
import { renderToString } from 'react-dom/server.browser'
import { NextResponse } from 'next/server'
import { getText } from '../../lib/utils'

export async function middleware(request, ev) {
// eslint-disable-next-line no-undef
Expand Down Expand Up @@ -36,7 +37,8 @@ export async function middleware(request, ev) {
ev.waitUntil(
(async () => {
writer.write(encoder.encode('this is a streamed '))
writer.write(encoder.encode('response'))
writer.write(encoder.encode('response '))
writer.write(encoder.encode(getText()))
writer.close()
})()
)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/middleware/core/test/index.test.js
Expand Up @@ -254,7 +254,7 @@ function responseTests(locale = '') {
`${locale}/responses/stream-a-response`
)
const html = await res.text()
expect(html).toBe('this is a streamed response')
expect(html).toBe('this is a streamed response with some text')
})

it(`${locale} should respond with a body`, async () => {
Expand Down

0 comments on commit c43d311

Please sign in to comment.