Skip to content

Commit 9c8f86d

Browse files
committed
test(axios): Test were failing because pinia instance was not set
1 parent b5c5752 commit 9c8f86d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import type { Model } from 'pinia-orm'
22
import { useRepo } from 'pinia-orm'
33
import { AxiosRepository } from '../repository/AxiosRepository'
4+
import { getActivePinia } from 'pinia'
45

56
export function useAxiosRepo<M extends Model> (model: M) {
7+
const pinia = getActivePinia()
68
AxiosRepository.useModel = model
7-
return useRepo(AxiosRepository)
9+
return useRepo(AxiosRepository, pinia)
810
}

packages/axios/test/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createPinia, setActivePinia } from 'pinia'
1+
import { createPinia, getActivePinia, setActivePinia } from 'pinia'
22
import { beforeAll, beforeEach } from 'vitest'
33
import { Vue2, createApp, install, isVue2 } from 'vue-demi'
44
import { Model, createORM, useRepo } from 'pinia-orm'
@@ -23,6 +23,7 @@ beforeEach(() => {
2323
pinia.use(piniaOrm)
2424
app.use(pinia)
2525
setActivePinia(pinia)
26+
console.log('Pinia init')
2627
Model.clearBootedModels()
2728
useRepo(Model).hydratedDataCache.clear()
2829
})

0 commit comments

Comments
 (0)