mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 06:46:04 +02:00
use oxfmt instead of prettier
This commit is contained in:
@@ -3,7 +3,10 @@ import { nextTick, ref } from 'vue';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
currentUser: { value: { currentAvatar: 'avtr_current', $previousAvatarSwapTime: 0 }, __v_isRef: true },
|
||||
currentUser: {
|
||||
value: { currentAvatar: 'avtr_current', $previousAvatarSwapTime: 0 },
|
||||
__v_isRef: true
|
||||
},
|
||||
modalConfirm: vi.fn(),
|
||||
configGetString: vi.fn(),
|
||||
configSetString: vi.fn(),
|
||||
@@ -76,7 +79,8 @@ vi.mock('../../../stores', () => ({
|
||||
|
||||
vi.mock('../../../coordinators/avatarCoordinator', () => ({
|
||||
applyAvatar: (...args) => mocks.applyAvatar(...args),
|
||||
selectAvatarWithoutConfirmation: (...args) => mocks.selectAvatarWithoutConfirmation(...args),
|
||||
selectAvatarWithoutConfirmation: (...args) =>
|
||||
mocks.selectAvatarWithoutConfirmation(...args),
|
||||
showAvatarDialog: (...args) => mocks.showAvatarDialog(...args)
|
||||
}));
|
||||
|
||||
@@ -140,7 +144,10 @@ vi.mock('../composables/useAvatarCardGrid.js', () => ({
|
||||
gridStyle: ref(() => ({ '--avatar-grid-columns': '1' })),
|
||||
chunkIntoRows: (items, prefix = 'row') =>
|
||||
Array.isArray(items)
|
||||
? items.map((item, index) => ({ key: `${prefix}:${index}`, items: [item] }))
|
||||
? items.map((item, index) => ({
|
||||
key: `${prefix}:${index}`,
|
||||
items: [item]
|
||||
}))
|
||||
: [],
|
||||
estimateRowHeight: () => 80,
|
||||
updateContainerWidth: vi.fn()
|
||||
@@ -215,7 +222,8 @@ vi.mock('../../../components/ui/badge', () => ({
|
||||
vi.mock('../../../components/ui/button', () => ({
|
||||
Button: {
|
||||
emits: ['click'],
|
||||
template: '<button data-testid="button" @click="$emit(\'click\')"><slot /></button>'
|
||||
template:
|
||||
'<button data-testid="button" @click="$emit(\'click\')"><slot /></button>'
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -248,7 +256,8 @@ vi.mock('../components/MyAvatarCard.vue', () => ({
|
||||
default: {
|
||||
props: ['avatar'],
|
||||
emits: ['click', 'context-action'],
|
||||
template: '<button data-testid="avatar-card" @click="$emit(\'click\')">{{ avatar.name }}</button>'
|
||||
template:
|
||||
'<button data-testid="avatar-card" @click="$emit(\'click\')">{{ avatar.name }}</button>'
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -278,7 +287,10 @@ describe('MyAvatars.vue', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
mocks.currentUser.value = { currentAvatar: 'avtr_current', $previousAvatarSwapTime: 0 };
|
||||
mocks.currentUser.value = {
|
||||
currentAvatar: 'avtr_current',
|
||||
$previousAvatarSwapTime: 0
|
||||
};
|
||||
mocks.modalConfirm.mockResolvedValue({ ok: true });
|
||||
mocks.configGetString.mockImplementation((key, defaultValue) => {
|
||||
if (key === 'VRCX_MyAvatarsViewMode') {
|
||||
@@ -286,7 +298,9 @@ describe('MyAvatars.vue', () => {
|
||||
}
|
||||
return Promise.resolve(defaultValue ?? '');
|
||||
});
|
||||
mocks.getAllAvatarTags.mockResolvedValue(new Map([['avtr_1', [{ tag: 'fun', color: null }]]]));
|
||||
mocks.getAllAvatarTags.mockResolvedValue(
|
||||
new Map([['avtr_1', [{ tag: 'fun', color: null }]]])
|
||||
);
|
||||
mocks.getAvatarTimeSpent.mockResolvedValue({ timeSpent: 1000 });
|
||||
mocks.processBulk.mockImplementation(async ({ handle, done }) => {
|
||||
handle({
|
||||
@@ -316,7 +330,9 @@ describe('MyAvatars.vue', () => {
|
||||
const wrapper = mount(MyAvatars);
|
||||
await flushAll();
|
||||
|
||||
expect(wrapper.find('[data-testid="table-layout"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="table-layout"]').exists()).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
test('persists view mode when toggled', async () => {
|
||||
@@ -325,7 +341,10 @@ describe('MyAvatars.vue', () => {
|
||||
|
||||
await wrapper.get('[data-testid="set-table"]').trigger('click');
|
||||
|
||||
expect(mocks.configSetString).toHaveBeenCalledWith('VRCX_MyAvatarsViewMode', 'table');
|
||||
expect(mocks.configSetString).toHaveBeenCalledWith(
|
||||
'VRCX_MyAvatarsViewMode',
|
||||
'table'
|
||||
);
|
||||
});
|
||||
|
||||
test('confirms and selects avatar when grid card is clicked', async () => {
|
||||
@@ -336,6 +355,8 @@ describe('MyAvatars.vue', () => {
|
||||
await flushAll();
|
||||
|
||||
expect(mocks.modalConfirm).toHaveBeenCalled();
|
||||
expect(mocks.selectAvatarWithoutConfirmation).toHaveBeenCalledWith('avtr_1');
|
||||
expect(mocks.selectAvatarWithoutConfirmation).toHaveBeenCalledWith(
|
||||
'avtr_1'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user