mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { generateGraphData } from '@/lib/graphUtils.ts';
|
|
import { Organization } from '@/types.ts';
|
|
|
|
vi.mock('../constants.tsx', () => ({
|
|
SECTORS: [
|
|
{ nameKey: 'technology', colorKey: 'blue', icon: null },
|
|
{ nameKey: 'agriculture', colorKey: 'green', icon: null },
|
|
{ nameKey: 'finance', colorKey: 'yellow', icon: null },
|
|
{ nameKey: 'healthcare', colorKey: 'red', icon: null },
|
|
{ nameKey: 'education', colorKey: 'purple', icon: null },
|
|
{ nameKey: 'manufacturing', colorKey: 'orange', icon: null },
|
|
{ nameKey: 'tourism', colorKey: 'teal', icon: null },
|
|
],
|
|
}));
|
|
|
|
const mockOrganizations: Organization[] = [
|
|
{
|
|
id: 'org-1',
|
|
name: 'Org One',
|
|
sector: 'technology',
|
|
needs: [{ resource: 'Software Engineers', quantity: 5, urgency: 'high' }],
|
|
offers: [{ resource: 'Web Development', quantity: 10, urgency: 'medium' }],
|
|
},
|
|
{
|
|
id: 'org-2',
|
|
name: 'Org Two',
|
|
sector: 'agriculture',
|
|
needs: [{ resource: 'Web Development', quantity: 1, urgency: 'low' }],
|
|
offers: [{ resource: 'Organic Produce', quantity: 100, urgency: 'high' }],
|
|
},
|
|
{
|
|
id: 'org-3',
|
|
name: 'Org Three',
|
|
sector: 'technology',
|
|
needs: [{ resource: 'Project Managers', quantity: 2, urgency: 'medium' }],
|
|
offers: [{ resource: 'Mobile App Development', quantity: 5, urgency: 'high' }],
|
|
},
|
|
];
|
|
|
|
const mockT = (key: string) => key;
|
|
|
|
describe('generateGraphData', () => {
|
|
it('should generate nodes and links correctly', () => {
|
|
const { nodes, links } = generateGraphData(mockOrganizations, mockT);
|
|
|
|
expect(nodes).toHaveLength(7);
|
|
expect(links).toHaveLength(1);
|
|
|
|
const techNode = nodes.find((n) => n.id === 'technology');
|
|
const agricultureNode = nodes.find((n) => n.id === 'agriculture');
|
|
|
|
expect(techNode?.orgCount).toBe(2);
|
|
expect(agricultureNode?.orgCount).toBe(1);
|
|
|
|
const link = links[0];
|
|
expect(link.source).toBe('agriculture');
|
|
expect(link.target).toBe('technology');
|
|
expect(link.value).toBe(1);
|
|
});
|
|
});
|