@@ -11,10 +11,7 @@ import {
1111 trimSlashes ,
1212 normalize ,
1313} from "../../src/common/util"
14- import { Cookie as CookieEnum } from "../../src/node/routes/login"
15- import { hash } from "../../src/node/util"
16- import { PASSWORD } from "../utils/constants"
17- import { checkForCookie , createCookieIfDoesntExist , loggerModule , Cookie } from "../utils/helpers"
14+ import { loggerModule } from "../utils/helpers"
1815
1916const dom = new JSDOM ( )
2017global . document = dom . window . document
@@ -252,58 +249,4 @@ describe("util", () => {
252249 expect ( loggerModule . logger . error ) . toHaveBeenCalledWith ( "api: oh no" )
253250 } )
254251 } )
255-
256- describe ( "checkForCookie" , ( ) => {
257- it ( "should check if the cookie exists and has a value" , ( ) => {
258- const fakeCookies : Cookie [ ] = [
259- {
260- name : CookieEnum . Key ,
261- value : hash ( PASSWORD ) ,
262- domain : "localhost" ,
263- secure : false ,
264- sameSite : "Lax" ,
265- httpOnly : false ,
266- expires : 18000 ,
267- path : "/" ,
268- } ,
269- ]
270- expect ( checkForCookie ( fakeCookies , CookieEnum . Key ) ) . toBe ( true )
271- } )
272- it ( "should return false if there are no cookies" , ( ) => {
273- const fakeCookies : Cookie [ ] = [ ]
274- expect ( checkForCookie ( fakeCookies , "key" ) ) . toBe ( false )
275- } )
276- } )
277-
278- describe ( "createCookieIfDoesntExist" , ( ) => {
279- it ( "should create a cookie if it doesn't exist" , ( ) => {
280- const cookies : Cookie [ ] = [ ]
281- const cookieToStore = {
282- name : CookieEnum . Key ,
283- value : hash ( PASSWORD ) ,
284- domain : "localhost" ,
285- secure : false ,
286- sameSite : "Lax" as const ,
287- httpOnly : false ,
288- expires : 18000 ,
289- path : "/" ,
290- }
291- expect ( createCookieIfDoesntExist ( cookies , cookieToStore ) ) . toStrictEqual ( [ cookieToStore ] )
292- } )
293- it ( "should return the same cookies if the cookie already exists" , ( ) => {
294- const PASSWORD = "123supersecure"
295- const cookieToStore = {
296- name : CookieEnum . Key ,
297- value : hash ( PASSWORD ) ,
298- domain : "localhost" ,
299- secure : false ,
300- sameSite : "Lax" as const ,
301- httpOnly : false ,
302- expires : 18000 ,
303- path : "/" ,
304- }
305- const cookies : Cookie [ ] = [ cookieToStore ]
306- expect ( createCookieIfDoesntExist ( cookies , cookieToStore ) ) . toStrictEqual ( cookies )
307- } )
308- } )
309252} )
0 commit comments