Files
twenty/packages/twenty-front/src/utils/__tests__/cookie-storage.test.ts
T
gitstart-twenty 5f7442cf23 Add jest tests for twenty-front (#2983)
* Add jest tests for twenty-front

Co-authored-by: v1b3m <vibenjamin6@gmail.com>

* Fix tests

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2023-12-15 10:53:20 +01:00

27 lines
868 B
TypeScript

import { cookieStorage } from '~/utils/cookie-storage';
describe('cookieStorage', () => {
it('should be able to set and get a cookie', () => {
cookieStorage.setItem('foo', 'bar');
expect(cookieStorage.getItem('foo')).toBe('bar');
});
it('should return undefined for a non-existent cookie', () => {
expect(cookieStorage.getItem('non-existent')).toBeUndefined();
});
it('should be able to remove a cookie', () => {
cookieStorage.setItem('foo', 'bar');
cookieStorage.removeItem('foo');
expect(cookieStorage.getItem('foo')).toBeUndefined();
});
it('should be able to clear all cookies', () => {
cookieStorage.setItem('foo', 'bar');
cookieStorage.setItem('baz', 'qux');
cookieStorage.clear();
expect(cookieStorage.getItem('foo')).toBeUndefined();
expect(cookieStorage.getItem('baz')).toBeUndefined();
});
});