test(frontend): update test imports to lib/ path, configure vitest.config.ts and vitest.setup.ts
This commit is contained in:
1 parent
7e072793eb
commit
cf5ab2030d
9 files changed
+1992
-37
No files matched your search
@@ -3,14 +3,14 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import CartDrawer from '../CartDrawer';
|
||||
import { useCartStore } from '../../store/cartStore';
|
||||
import { productService } from '../../services/productService';
|
||||
import { useCartStore } from '../../lib/store/cartStore';
|
||||
import { productService } from '../../lib/services/productService';
|
||||
|
||||
vi.mock('../../store/cartStore', () => ({
|
||||
vi.mock('../../lib/store/cartStore', () => ({
|
||||
useCartStore: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../../services/productService', () => ({
|
||||
vi.mock('../../lib/services/productService', () => ({
|
||||
productService: {
|
||||
getProducts: vi.fn(),
|
||||
},
|
||||
@@ -28,7 +28,7 @@ const mockProduct = {
|
||||
describe('CartDrawer', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(productService.getProducts).mockResolvedValue([]);
|
||||
vi.mocked(productService.getProducts).mockResolvedValue({ data: [] } as any);
|
||||
});
|
||||
|
||||
it('renders empty cart state when no items in cart', () => {
|
||||
|
||||
@@ -3,16 +3,16 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import FeaturedProducts from '../FeaturedProducts';
|
||||
import { productService } from '../../services/productService';
|
||||
import { usePetStore } from '../../store/usePetStore';
|
||||
import { productService } from '../../lib/services/productService';
|
||||
import { usePetStore } from '../../lib/store/usePetStore';
|
||||
|
||||
vi.mock('../../services/productService', () => ({
|
||||
vi.mock('../../lib/services/productService', () => ({
|
||||
productService: {
|
||||
getFeaturedProducts: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock('../../store/usePetStore', () => ({
|
||||
vi.mock('../../lib/store/usePetStore', () => ({
|
||||
usePetStore: vi.fn(),
|
||||
}));
|
||||
|
||||
|
||||
@@ -3,19 +3,19 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import Header from '../Header';
|
||||
import { useCartStore } from '../../store/cartStore';
|
||||
import { usePetStore } from '../../store/usePetStore';
|
||||
import { useUserStore } from '../../store/userStore';
|
||||
import { useCartStore } from '../../lib/store/cartStore';
|
||||
import { usePetStore } from '../../lib/store/usePetStore';
|
||||
import { useUserStore } from '../../lib/store/userStore';
|
||||
|
||||
vi.mock('../../store/cartStore', () => ({
|
||||
vi.mock('../../lib/store/cartStore', () => ({
|
||||
useCartStore: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../../store/usePetStore', () => ({
|
||||
vi.mock('../../lib/store/usePetStore', () => ({
|
||||
usePetStore: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../../store/userStore', () => ({
|
||||
vi.mock('../../lib/store/userStore', () => ({
|
||||
useUserStore: vi.fn(),
|
||||
}));
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import Hero from '../Hero';
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
import { useSettingsStore } from '../../lib/store/settingsStore';
|
||||
|
||||
vi.mock('../../store/settingsStore', () => ({
|
||||
vi.mock('../../lib/store/settingsStore', () => ({
|
||||
useSettingsStore: vi.fn(),
|
||||
}));
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import Tooltip from '../Tooltip';
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
import { useSettingsStore } from '../../lib/store/settingsStore';
|
||||
|
||||
vi.mock('../../store/settingsStore', () => ({
|
||||
vi.mock('../../lib/store/settingsStore', () => ({
|
||||
useSettingsStore: vi.fn(),
|
||||
}));
|
||||
|
||||
|
||||
Reference in new issue
Block a user