chore: add vitest script, example unit test

This commit is contained in:
DongjaJ 2024-10-16 10:30:15 +09:00
parent 7369cea4d2
commit ea96ec8553
2 changed files with 18 additions and 1 deletions

View file

@ -7,7 +7,9 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"preview": "vite preview",
"test": "vitest",
"test:ui": "vitest --ui"
},
"dependencies": {
"@headlessui/react": "^1.7.17",

View file

@ -0,0 +1,15 @@
import { setLocalStorage } from "./localStorage";
describe("localStorage Test", () => {
beforeEach(() => {
localStorage.clear();
});
it("should stringify and set value in localStorage", () => {
const MOCK_ONBOARDING_STATUS_VALUE = "Started";
setLocalStorage("onboardingStatus", MOCK_ONBOARDING_STATUS_VALUE);
expect(JSON.parse(localStorage.getItem("onboardingStatus") || "")).toEqual(
MOCK_ONBOARDING_STATUS_VALUE,
);
});
});