forked from SpaceCowboy326/open_data_gvl
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d48dbfa
commit fddc752
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import { setActivePinia, createPinia } from "pinia"; | ||
import { useUIStore } from "../../stores/ui"; | ||
|
||
describe("uiStore", () => { | ||
const primeTheStore = (initBannerVisibility: boolean | null) => { | ||
if (initBannerVisibility !== null) { | ||
sessionStorage.setItem( | ||
"disableHGLabsMapBanner", | ||
initBannerVisibility.toString(), | ||
); | ||
} | ||
|
||
setActivePinia(createPinia()); | ||
}; | ||
|
||
it("Upon first visit showContributionBanner is true", () => { | ||
primeTheStore(null); | ||
|
||
const uiStore = useUIStore(); | ||
expect(uiStore.showContributionBanner).toStrictEqual(true); | ||
}); | ||
|
||
it("User closes the banner", () => { | ||
primeTheStore(null); | ||
expect(sessionStorage.getItem("disableHGLabsMapBanner")).toStrictEqual( | ||
null, | ||
); | ||
|
||
const uiStore = useUIStore(); | ||
//Action triggered once someone closes the banner | ||
uiStore.setShowContributionBanner(false); | ||
|
||
expect(sessionStorage.getItem("disableHGLabsMapBanner")).toStrictEqual( | ||
"false", | ||
); | ||
expect(uiStore.showContributionBanner).toStrictEqual(false); | ||
}); | ||
|
||
it("User reloads page after previously closing banner in session", () => { | ||
primeTheStore(false); | ||
|
||
const uiStore = useUIStore(); | ||
|
||
expect(sessionStorage.getItem("disableHGLabsMapBanner")).toStrictEqual( | ||
"false", | ||
); | ||
expect(uiStore.showContributionBanner).toStrictEqual(false); | ||
}); | ||
}); |