fix: cookies.get should be able to filter domain (#20471)

* fix: use GetAllCookies when url is empty

* test: get cookie without url
This commit is contained in:
Cheng Zhao 2019-10-09 15:57:40 +09:00 committed by GitHub
parent ebd55c1147
commit 5e11be6898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 20 deletions

View file

@ -83,6 +83,16 @@ describe('session module', () => {
expect(cs.some(c => c.name === name && c.value === value)).to.equal(true)
})
it('gets cookies without url', async () => {
const { cookies } = session.defaultSession
const name = '1'
const value = '1'
await cookies.set({ url, name, value, expirationDate: (+new Date) / 1000 + 120 })
const cs = await cookies.get({ domain: '127.0.0.1' })
expect(cs.some(c => c.name === name && c.value === value)).to.equal(true)
})
it('yields an error when setting a cookie with missing required fields', async () => {
const { cookies } = session.defaultSession
const name = '1'