Skip to content

Commit

Permalink
perf(helper/cookie): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Nov 1, 2024
1 parent ab49303 commit 63f26ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/helper/cookie/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ describe('Cookie Middleware', () => {

expect(res.headers.get('Yummy-Cookie')).toBe('choco')
expect(res.headers.get('Tasty-Cookie')).toBe('strawberry')
expect(res.headers.get('No-Such-Cookie')).toBeNull()
})
})

Expand Down Expand Up @@ -96,7 +95,6 @@ describe('Cookie Middleware', () => {
const res = await app.request(req)
expect(res.headers.get('Fortune-Cookie')).toBe('lots-of-money')
expect(res.headers.get('Fruit-Cookie')).toBe('INVALID')
expect(res.headers.get('No-Such-Cookie')).toBeNull()
})

it('Get signed cookie', async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/cookie.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('Parse cookie', () => {
const cookie: Cookie = parse(cookieString)
expect(cookie['yummy_cookie']).toBe('choco')
expect(cookie['tasty_cookie']).toBe('strawberry')
expect(cookie['no_such_cookie']).toBeUndefined()
})

it('Should parse quoted cookie values', () => {
Expand Down Expand Up @@ -37,6 +38,7 @@ describe('Parse cookie', () => {
expect(cookie['tasty_cookie']).toBe('')
expect(cookie['best_cookie']).toBe('')
expect(cookie['last_cookie']).toBe('')
expect(cookie['no_such_cookie']).toBeUndefined()
})

it('Should parse cookies but not process signed cookies', () => {
Expand All @@ -48,6 +50,7 @@ describe('Parse cookie', () => {
expect(cookie['tasty_cookie']).toBe('strawberry.I9qAeGQOvWjCEJgRPmrw90JjYpnnX2C9zoOiGSxh1Ig=')
expect(cookie['great_cookie']).toBe('rating3.5')
expect(cookie['best_cookie']).toBe('sugar.valueShapedLikeASignatureButIsNotASignature=')
expect(cookie['no_such_cookie']).toBeUndefined()
})

it('Should ignore invalid cookie names', () => {
Expand Down

0 comments on commit 63f26ad

Please sign in to comment.