Skip to content

Commit

Permalink
build cookie function test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobia committed Jan 13, 2024
1 parent 3de3a70 commit 4af3100
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions __tests__/util/http.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CookieOptions } from '../../lib';
import { buildCookie } from '../../lib/util/http';

describe('buildCookie', () => {
it('should build a cookie string with the provided options', () => {
const cookie = 'myCookie';
const options: CookieOptions = {
expires: new Date('2022-12-31'),
httpOnly: true,
secure: true,
path: '/my-path',
domain: 'example.com',
sameSite: 'Strict'
};

const expectedCookieString =
'myCookie; Expires=Sat, 31 Dec 2022 00:00:00 GMT; HttpOnly; Secure; Path=/my-path; Domain=example.com; SameSite=Strict';
const result = buildCookie(cookie, options);

expect(result).toEqual(expectedCookieString);
});
});
2 changes: 1 addition & 1 deletion lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Request,
StatusCodes,
ConsumeRoute
} from './@types/index';
} from './@types';
import ConsumeRequest from './wrapper/request';
import security from './security/securityMiddleware';
import { isMiddleware } from './util/function';
Expand Down

0 comments on commit 4af3100

Please sign in to comment.