- Replace for...in with Object.keys() in deleteLocalStorageByKeyPattern
- Remove dead $route/$router globalProperties from ChargingStationsView
test (component now uses useRoute/useRouter composables via vi.mock)
* @param pattern - Substring to match against localStorage keys
*/
export const deleteLocalStorageByKeyPattern = (pattern: string): void => {
- const keysToDelete: string[] = []
- for (const key in getLocalStorage()) {
- if (key.includes(pattern)) {
- keysToDelete.push(key)
- }
- }
+ const keysToDelete = Object.keys(localStorage).filter(key => key.includes(pattern))
for (const key of keysToDelete) {
deleteFromLocalStorage(key)
}
return mount(ChargingStationsView, {
global: {
- config: {
- globalProperties: {
- $route: { name: 'charging-stations', params: {}, query: {} },
- $router: { back: vi.fn(), push: vi.fn(), replace: vi.fn() },
- } as never,
- },
provide: {
[chargingStationsKey as symbol]: ref(chargingStations),
[configurationKey as symbol]: ref(configuration),