describe('LayoutHeaderLocation.vue', () => {
const createWrapper = async (initialState = { id: 1, canChange: true, title: 'Астрахань' }) => {
.....
return await mountSuspended(LayoutHeaderLocation);
};
beforeEach(() => {
vi.clearAllMocks();
vi.resetAllMocks();
mockNuxtImport('useCookie', () => () => ({ value: 0 }));
});
it('there isn't cookie', async () => {
mockNuxtImport('useCookie', () => {
console.log('Mock useCookie with value 0');
return () => ({ value: 0 });
});
const wrapper = await createWrapper({ id: 1, canChange: true, title: 'Астрахань' });
await flushPromises();
await wrapper.vm.$nextTick();
console.log('locationConfirmationIsHidden (test куки нет):', wrapper.vm.locationConfirmationIsHidden?.value);
});
it('there is cookie', async () => {
mockNuxtImport('useCookie', () => {
console.log('Mock useCookie with value 1');
return () => ({ value: 1 });
});
const wrapper = await createWrapper({ id: 1, canChange: true, title: 'Астрахань' });
await flushPromises();
await wrapper.vm.$nextTick();
console.log('locationConfirmationIsHidden (there isnt't cookie):', wrapper.vm.locationConfirmationIsHidden?.value);
});
describe('LayoutHeaderLocation.vue', () => {
const createWrapper = async (initialState = { id: 1, canChange: true, title: 'Астрахань' }) => {
.....
return await mountSuspended(LayoutHeaderLocation);
};
beforeEach(() => {
vi.clearAllMocks();
vi.resetAllMocks();
mockNuxtImport('useCookie', () => () => ({ value: 0 }));
});
it('there isn't cookie', async () => {
mockNuxtImport('useCookie', () => {
console.log('Mock useCookie with value 0');
return () => ({ value: 0 });
});
const wrapper = await createWrapper({ id: 1, canChange: true, title: 'Астрахань' });
await flushPromises();
await wrapper.vm.$nextTick();
console.log('locationConfirmationIsHidden (test куки нет):', wrapper.vm.locationConfirmationIsHidden?.value);
});
it('there is cookie', async () => {
mockNuxtImport('useCookie', () => {
console.log('Mock useCookie with value 1');
return () => ({ value: 1 });
});
const wrapper = await createWrapper({ id: 1, canChange: true, title: 'Астрахань' });
await flushPromises();
await wrapper.vm.$nextTick();
console.log('locationConfirmationIsHidden (there isnt't cookie):', wrapper.vm.locationConfirmationIsHidden?.value);
});