removed jest-localstorage-mock dep

Signed-off-by: Manuel Scurti <manuel.scurti@agilelab.it>
This commit is contained in:
Manuel Scurti
2023-09-12 15:18:32 +02:00
parent 21e8ef916b
commit 3d8324e530
5 changed files with 21 additions and 8 deletions
-4
View File
@@ -20,7 +20,6 @@ import { default as CSS_2 } from 'csstype';
import { CSSProperties } from 'react';
import { ElementType } from 'react';
import { ErrorInfo } from 'react';
import { EventsType } from 'react-idle-timer';
import { IconComponent } from '@backstage/core-plugin-api';
import { Icons } from '@material-table/core';
import { IdentityApi } from '@backstage/core-plugin-api';
@@ -80,9 +79,6 @@ export type AutoLogoutProps = {
logoutIfDisconnected?: boolean;
};
// @public (undocumented)
export type AutoLogoutTrackableEvent = EventsType;
// @public
export function Avatar(props: AvatarProps): React_2.JSX.Element;
-1
View File
@@ -103,7 +103,6 @@
"@types/react-window": "^1.8.5",
"@types/zen-observable": "^0.8.0",
"cross-fetch": "^3.1.5",
"jest-localstorage-mock": "^2.4.26",
"msw": "^1.0.0"
},
"files": [
@@ -36,8 +36,7 @@ import {
import { StillTherePrompt } from './StillTherePrompt';
import { DefaultTimestampStore, TimestampStore } from './timestampStore';
/** @public */
export type AutoLogoutTrackableEvent = EventsType;
type AutoLogoutTrackableEvent = EventsType;
/** @public */
export type AutoLogoutProps = {
@@ -16,6 +16,20 @@
import { DefaultTimestampStore, TimestampStore } from './timestampStore';
const mockLocalStorage: any = {
__STORE__: {},
getItem: jest.fn(key => mockLocalStorage.__STORE__[key] || null),
setItem: jest.fn((key, value) => {
mockLocalStorage.__STORE__[key] = value;
}),
removeItem: jest.fn(key => {
delete mockLocalStorage.__STORE__[key];
}),
clear: jest.fn(() => {
mockLocalStorage.__STORE__ = {};
}),
};
describe('DefaultTimestampStore', () => {
let timestampStore: TimestampStore;
const key = 'test-key';
@@ -23,6 +37,12 @@ describe('DefaultTimestampStore', () => {
beforeEach(() => {
timestampStore = new DefaultTimestampStore(key);
// Set up mock localStorage
Object.defineProperty(window, 'localStorage', {
value: mockLocalStorage,
});
// Clear the mock storage before each test
localStorage.clear();
});
@@ -15,4 +15,3 @@
*/
import '@testing-library/jest-dom';
import 'jest-localstorage-mock';