Files
cloudbeaver/webapp/packages/core-utils/src/getCookies.test.ts
T
alex c2c7a94936 chore: add some tests (#1358)
* chore: add some tests

* mock date in generateFileName test
2023-02-10 13:41:14 +01:00

39 lines
1009 B
TypeScript

/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2022 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { getCookies } from './getCookies';
describe('getCookies', () => {
beforeEach(() => {
// mock the `document.cookie` property
Object.defineProperty(document, 'cookie', {
value: 'foo=bar; baz=qux',
writable: true,
});
});
it('should return an object with the cookies', () => {
const cookies = getCookies();
// assert that the `cookies` object has the correct keys and values
expect(cookies).toEqual({
foo: 'bar',
baz: 'qux',
});
});
it('should return an empty object if no cookies are present', () => {
// set the `document.cookie` property to an empty string
document.cookie = '';
const cookies = getCookies();
// assert that the `cookies` object is empty
expect(cookies).toEqual({});
});
});