You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{beforeEach,describe,expect,it,vi}from'vitest'import{setActivePinia,createPinia}from'pinia'import{useThemeStore}from'@/stores/themeStore'importpiniaPluginPersistedstatefrom'pinia-plugin-persistedstate'describe('useThemeStore',()=>{constsetItemFn=vi.fn()constgetItemFn=vi.fn()beforeEach(()=>{vi.stubGlobal('localStorage',{getItem: getItemFn,setItem: setItemFn,clear: vi.fn(),})constpinia=createPinia()pinia.use(piniaPluginPersistedstate)setActivePinia(pinia)})it('should have "light" as the default theme',()=>{conststore=useThemeStore()expect(store.currentTheme).toBe('light')})it('should change the theme when setTheme is called',()=>{conststore=useThemeStore()store.setTheme('dark')expect(store.currentTheme).toBe('dark')})it.skip('should persist the theme in local storage',async()=>{conststore=useThemeStore()store.setTheme('dark')expect(setItemFn).toHaveBeenCalledWith('theme',JSON.stringify({currentTheme: 'dark'}),)})})
Clear and concise description of the problem
localStorage.setItem not be called
Suggested solution
Please provide a way to test persist function
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: