Skip to content

Commit b1d12fd

Browse files
committed
Update invalid export tests
1 parent 5822d27 commit b1d12fd

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

test/integration/export-serverless/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = phase => {
2929
query: { text: 'this file has an extension' },
3030
},
3131
'/query': { page: '/query', query: { a: 'blue' } },
32+
'/query-update': { page: '/query-update', query: { a: 'blue' } },
3233
// API route
3334
'/blog/nextjs/comment/test': { page: '/blog/[post]/comment/[id]' },
3435
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { useRouter } from 'next/router'
2+
3+
const Page = () => <div id="query">{JSON.stringify(useRouter().query)}</div>
4+
5+
Page.getInitialProps = () => ({ hello: 'world' })
6+
7+
export default Page

test/integration/export-serverless/test/browser.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ export default function(context) {
183183
})
184184

185185
it('should update query after mount', async () => {
186-
const browser = await webdriver(context.port, '/query?hello=1')
187-
188-
await waitFor(1000)
189-
const text = await browser.eval('document.body.innerHTML')
190-
expect(text).toMatch(/hello/)
186+
const browser = await webdriver(context.port, '/query-update?hello=world')
187+
await waitFor(2000)
188+
const query = await browser.elementByCss('#query').text()
189+
expect(JSON.parse(query)).toEqual({ hello: 'world', a: 'blue' })
191190
await browser.close()
192191
})
193192

test/integration/export/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = phase => {
3434
query: { text: 'this file has an extension' },
3535
},
3636
'/query': { page: '/query', query: { a: 'blue' } },
37+
'/query-update': { page: '/query-update', query: { a: 'blue' } },
3738
// API route
3839
'/blog/nextjs/comment/test': { page: '/blog/[post]/comment/[id]' },
3940
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { useRouter } from 'next/router'
2+
3+
const Page = () => <div id="query">{JSON.stringify(useRouter().query)}</div>
4+
5+
Page.getInitialProps = () => ({ hello: 'world' })
6+
7+
export default Page

test/integration/export/test/browser.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ export default function(context) {
183183
})
184184

185185
it('should update query after mount', async () => {
186-
const browser = await webdriver(context.port, '/query?hello=1')
187-
188-
await waitFor(1000)
189-
const text = await browser.eval('document.body.innerHTML')
190-
expect(text).toMatch(/hello/)
186+
const browser = await webdriver(context.port, '/query-update?hello=world')
187+
await waitFor(2000)
188+
const query = await browser.elementByCss('#query').text()
189+
expect(JSON.parse(query)).toEqual({ hello: 'world', a: 'blue' })
191190
await browser.close()
192191
})
193192

0 commit comments

Comments
 (0)