mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-21 07:43:50 +02:00
refactor store
This commit is contained in:
@@ -18,23 +18,26 @@ const mocks = vi.hoisted(() => ({
|
||||
},
|
||||
userStore: {
|
||||
cachedUsers: new Map(),
|
||||
showUserDialog: vi.fn(),
|
||||
showSendBoopDialog: vi.fn()
|
||||
},
|
||||
groupStore: {
|
||||
showGroupDialog: vi.fn()
|
||||
},
|
||||
groupStore: {},
|
||||
locationStore: {
|
||||
lastLocation: { value: { location: 'wrld_home:123' } }
|
||||
},
|
||||
gameStore: {
|
||||
isGameRunning: { value: true }
|
||||
}
|
||||
},
|
||||
showUserDialog: vi.fn(),
|
||||
showGroupDialog: vi.fn()
|
||||
}));
|
||||
|
||||
vi.mock('pinia', () => ({
|
||||
storeToRefs: (store) => store
|
||||
}));
|
||||
vi.mock('pinia', async (importOriginal) => {
|
||||
const actual = await importOriginal();
|
||||
return {
|
||||
...actual,
|
||||
storeToRefs: (store) => store
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('../../../../stores', () => ({
|
||||
useNotificationStore: () => mocks.notificationStore,
|
||||
@@ -44,6 +47,14 @@ vi.mock('../../../../stores', () => ({
|
||||
useGameStore: () => mocks.gameStore
|
||||
}));
|
||||
|
||||
vi.mock('../../../../coordinators/userCoordinator', () => ({
|
||||
showUserDialog: (...args) => mocks.showUserDialog(...args)
|
||||
}));
|
||||
|
||||
vi.mock('../../../../coordinators/groupCoordinator', () => ({
|
||||
showGroupDialog: (...args) => mocks.showGroupDialog(...args)
|
||||
}));
|
||||
|
||||
vi.mock('../../../../shared/utils', () => ({
|
||||
checkCanInvite: vi.fn(() => true),
|
||||
userImage: vi.fn(() => 'https://example.com/avatar.png')
|
||||
@@ -155,9 +166,9 @@ describe('NotificationItem.vue', () => {
|
||||
mocks.notificationStore.queueMarkAsSeen.mockReset();
|
||||
mocks.notificationStore.openNotificationLink.mockReset();
|
||||
mocks.notificationStore.isNotificationExpired.mockReturnValue(false);
|
||||
mocks.userStore.showUserDialog.mockReset();
|
||||
mocks.showUserDialog.mockReset();
|
||||
mocks.userStore.showSendBoopDialog.mockReset();
|
||||
mocks.groupStore.showGroupDialog.mockReset();
|
||||
mocks.showGroupDialog.mockReset();
|
||||
mocks.userStore.cachedUsers = new Map();
|
||||
});
|
||||
|
||||
@@ -170,7 +181,7 @@ describe('NotificationItem.vue', () => {
|
||||
|
||||
expect(wrapper.text()).toContain('Alice');
|
||||
await wrapper.get('span.truncate.cursor-pointer').trigger('click');
|
||||
expect(mocks.userStore.showUserDialog).toHaveBeenCalledWith('usr_123');
|
||||
expect(mocks.showUserDialog).toHaveBeenCalledWith('usr_123');
|
||||
});
|
||||
|
||||
test('clicking accept icon calls acceptFriendRequestNotification', async () => {
|
||||
|
||||
Reference in New Issue
Block a user