Skip to content

Commit

Permalink
IS-1940: Fix localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
vetlesolgaard committed Jan 9, 2024
1 parent 2fe530d commit 4bf0a77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"author": "DigiSyfo <[email protected]>",
"license": "ISC",
"dependencies": {
"@amplitude/analytics-browser": "^2.3.8",
"@amplitude/analytics-browser": "2.3.8",
"@navikt/aksel-icons": "5.11.2",
"@navikt/ds-css": "5.11.1",
"@navikt/ds-react": "5.11.1",
Expand Down
5 changes: 1 addition & 4 deletions src/containers/OversiktContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ const OversiktContainer = ({ tabType }: Props): ReactElement => {
const personregisterQuery = usePersonregisterQuery();
const personoversiktQuery = usePersonoversiktQuery();
const { setTabType } = useTabType();
useEffect(() => {
logPageView(tabType);
}, [tabType]);

useEffect(() => {
setTabType(tabType);
logPageView(tabType);
}, [setTabType, tabType]);

const ContainerContent = (): ReactElement => {
Expand Down
22 changes: 12 additions & 10 deletions test/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ function copyProps(src: any, target: any) {
Object.defineProperties(target, propsAsPropertyDescriptorMap);
}

let temp: any = null;
const localS = {
getItem() {
return temp;
},
setItem(key: any, value: any) {
temp = value;
},
};
function localStorage() {
let storage = {};
return {
getItem: function (key: string) {
return key in storage ? (storage as any)[key] : null;
},
setItem: function (key: string, value: any) {
(storage as any)[key] = value || '';
},
};
}

(global as any).HTMLElement = window.HTMLElement;
(global as any).localStorage = localS;
(global as any).localStorage = localStorage();
(global as any).XMLHttpRequest = window.XMLHttpRequest;

(global as any).window = window;
Expand Down

0 comments on commit 4bf0a77

Please sign in to comment.