25 lines
977 B
TypeScript
25 lines
977 B
TypeScript
import { SHOP_SURFACE_HEADER_NAME } from '../consts/shopSurfaceHeader';
|
|
import { NodeEnv } from '../types/NodeEnv';
|
|
import { ShopSurface } from '../types/ShopSurface';
|
|
import { shouldUseSecureCookie } from './shouldUseSecureCookie';
|
|
|
|
describe('shouldUseSecureCookie', () => {
|
|
it('returns true only for production clearnet requests', () => {
|
|
const req = { headers: { [SHOP_SURFACE_HEADER_NAME]: ShopSurface.Clearnet } };
|
|
|
|
expect(shouldUseSecureCookie(NodeEnv.Production, req)).toBe(true);
|
|
});
|
|
|
|
it('returns false for production onion requests', () => {
|
|
const req = { headers: { [SHOP_SURFACE_HEADER_NAME]: ShopSurface.Onion } };
|
|
|
|
expect(shouldUseSecureCookie(NodeEnv.Production, req)).toBe(false);
|
|
});
|
|
|
|
it('returns false outside production', () => {
|
|
const req = { headers: { [SHOP_SURFACE_HEADER_NAME]: ShopSurface.Clearnet } };
|
|
|
|
expect(shouldUseSecureCookie(NodeEnv.Development, req)).toBe(false);
|
|
});
|
|
});
|