Skip to content

Commit

Permalink
Add test for getServerSideProps reading cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Sep 14, 2023
1 parent 7e49a89 commit 21278b1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/integration/typescript/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const handleOutput = (msg) => {
output += msg
}

async function get$(path, query) {
const html = await renderViaHTTP(appPort, path, query)
async function get$(path, query, options) {
const html = await renderViaHTTP(appPort, path, query, options)
return cheerio.load(html)
}

Expand All @@ -49,6 +49,19 @@ describe('TypeScript Features', () => {
expect($('#cookies').text()).toBe('{}')
})

it('should render the cookies page with cookies', async () => {
const $ = await get$(
'/ssr/cookies',
{},
{
headers: {
Cookie: 'key=value;',
},
}
)
expect($('#cookies').text()).toBe(`{"key":"value"}`)
})

it('should render the generics page', async () => {
const $ = await get$('/generics')
expect($('#value').text()).toBe('Hello World from Generic')
Expand Down

0 comments on commit 21278b1

Please sign in to comment.