Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
store.n++
expect(spy).toHaveBeenCalledTimes(1)
})
+
+ it('only executes plugins once after multiple installs', async () => {
+ const pinia = createPinia()
+
+ const spy = jest.fn()
+ pinia.use(spy)
+
+ for (let i = 0; i < 3; i++) {
+ mount({ template: 'none' }, { global: { plugins: [pinia] } }).unmount()
+ }
+
+ useStore(pinia)
+
+ expect(spy).toHaveBeenCalledTimes(1)
+ })
})
let _p: Pinia['_p'] = []
// plugins added before calling app.use(pinia)
- const toBeInstalled: PiniaStorePlugin[] = []
+ let toBeInstalled: PiniaStorePlugin[] = []
const pinia: Pinia = markRaw({
install(app: App) {
registerPiniaDevtools(app, pinia)
}
toBeInstalled.forEach((plugin) => _p.push(plugin))
+ toBeInstalled = []
}
},