test: add test for invalid cookie url (#18751)

Co-Authored-By: Erick Zhao <erick@hotmail.ca>
This commit is contained in:
Micha Hanselmann 2019-06-12 19:49:36 -07:00 committed by Shelley Vohr
parent ba96cdb7dc
commit ddec3c0e78
2 changed files with 18 additions and 7 deletions

View file

@ -88,12 +88,23 @@ describe('session module', () => {
})
it('yields an error when setting a cookie with missing required fields', async () => {
await expect((async () => {
const { cookies } = session.defaultSession
const name = '1'
const value = '1'
await cookies.set({ url: '', name, value })
})()).to.eventually.be.rejectedWith('Failed to get cookie domain')
const { cookies } = session.defaultSession
const name = '1'
const value = '1'
await expect(
cookies.set({ url: '', name, value })
).to.eventually.be.rejectedWith('Failed to get cookie domain')
})
it('yields an error when setting a cookie with an invalid URL', async () => {
const { cookies } = session.defaultSession
const name = '1'
const value = '1'
await expect(
cookies.set({ url: 'asdf', name, value })
).to.eventually.be.rejectedWith('Failed to get cookie domain')
})
it('should overwrite previous cookies', async () => {