style: auto-format codebase with Prettier

Applied formatting to 1487+ files using pnpm format:write
  - TypeScript/JavaScript files
  - Svelte components
  - Astro pages
  - JSON configs
  - Markdown docs

  13 files still need manual review (Astro JSX comments)
This commit is contained in:
Wuesteon 2025-11-27 18:33:16 +01:00
parent 0241f5554c
commit d36b321d9d
3952 changed files with 661498 additions and 739751 deletions

View file

@ -25,7 +25,9 @@ test-examples/
### Backend Tests (NestJS)
#### `example.controller.spec.ts`
Demonstrates:
- Controller unit testing with mocked services
- Request/response handling
- Authentication/authorization testing
@ -34,13 +36,16 @@ Demonstrates:
- CRUD operations
**Key Patterns**:
- Use `@nestjs/testing` TestingModule
- Mock all service dependencies
- Test both success and error paths
- Verify service method calls
#### `example.service.spec.ts`
Demonstrates:
- Service business logic testing
- Database operation mocking
- External API mocking
@ -49,6 +54,7 @@ Demonstrates:
- Authorization checks
**Key Patterns**:
- Mock database and external services
- Test error handling thoroughly
- Verify data transformations
@ -57,7 +63,9 @@ Demonstrates:
### Mobile Tests (React Native)
#### `ExampleComponent.test.tsx`
Demonstrates:
- Component rendering
- User interactions (press, long press)
- State management
@ -67,13 +75,16 @@ Demonstrates:
- Snapshot testing
**Key Patterns**:
- Use `@testing-library/react-native`
- Test user behavior, not implementation
- Verify accessibility props
- Test loading and error states
#### `authService.test.ts`
Demonstrates:
- Async service testing
- API call mocking with fetch
- Storage operations (SecureStore)
@ -82,6 +93,7 @@ Demonstrates:
- Integration with other services
**Key Patterns**:
- Mock global fetch
- Mock Expo modules (SecureStore)
- Test timeout scenarios
@ -90,7 +102,9 @@ Demonstrates:
### Web Tests (SvelteKit)
#### `Button.test.ts`
Demonstrates:
- Svelte 5 component testing
- Reactive state with runes ($state, $derived)
- User events
@ -100,13 +114,16 @@ Demonstrates:
- Debouncing
**Key Patterns**:
- Use `@testing-library/svelte`
- Test Svelte 5 reactivity
- Verify accessibility attributes
- Test custom event dispatch
#### `page.server.test.ts`
Demonstrates:
- Server load function testing
- Form action testing
- Database mocking (PocketBase)
@ -116,6 +133,7 @@ Demonstrates:
- File upload handling
**Key Patterns**:
- Mock `locals` object
- Mock database client
- Test redirect behavior
@ -125,7 +143,9 @@ Demonstrates:
### Shared Package Tests
#### `format.test.ts`
Demonstrates:
- Pure function testing
- Parameterized tests (it.each)
- Edge case testing
@ -135,6 +155,7 @@ Demonstrates:
- Unicode and emoji handling
**Key Patterns**:
- Test with multiple inputs using `it.each`
- Cover edge cases thoroughly
- Test security vulnerabilities
@ -180,6 +201,7 @@ jest.mock('@your-project/custom-service', () => ({
### 4. Reference Best Practices
Each file includes comments explaining:
- Why specific patterns are used
- What to test and what not to test
- Common pitfalls to avoid

View file

@ -85,11 +85,15 @@ describe('ExampleController', () => {
error: new Error('Validation failed'),
});
await expect(controller.create(invalidDto, { user: mockUser })).rejects.toThrow(BadRequestException);
await expect(controller.create(invalidDto, { user: mockUser })).rejects.toThrow(
BadRequestException
);
});
it('should throw UnauthorizedException when user is not authenticated', async () => {
await expect(controller.create(createDto, { user: null })).rejects.toThrow(UnauthorizedException);
await expect(controller.create(createDto, { user: null })).rejects.toThrow(
UnauthorizedException
);
});
it('should handle service errors gracefully', async () => {
@ -155,7 +159,9 @@ describe('ExampleController', () => {
error: new Error('Not found'),
});
await expect(controller.findOne('invalid-id', { user: mockUser })).rejects.toThrow(NotFoundException);
await expect(controller.findOne('invalid-id', { user: mockUser })).rejects.toThrow(
NotFoundException
);
});
it('should not allow access to other users examples', async () => {
@ -166,7 +172,9 @@ describe('ExampleController', () => {
error: null,
});
await expect(controller.findOne(exampleId, { user: mockUser })).rejects.toThrow(UnauthorizedException);
await expect(controller.findOne(exampleId, { user: mockUser })).rejects.toThrow(
UnauthorizedException
);
});
});
@ -236,7 +244,9 @@ describe('ExampleController', () => {
error: new Error('Not found'),
});
await expect(controller.remove('invalid-id', { user: mockUser })).rejects.toThrow(NotFoundException);
await expect(controller.remove('invalid-id', { user: mockUser })).rejects.toThrow(
NotFoundException
);
});
it('should not allow deletion of other users examples', async () => {
@ -245,7 +255,9 @@ describe('ExampleController', () => {
error: new Error('Unauthorized'),
});
await expect(controller.remove(exampleId, { user: mockUser })).rejects.toThrow(UnauthorizedException);
await expect(controller.remove(exampleId, { user: mockUser })).rejects.toThrow(
UnauthorizedException
);
});
});
});

View file

@ -36,7 +36,9 @@ describe('ExampleComponent', () => {
});
it('should render with testID for automation', () => {
const { getByTestId } = render(<ExampleComponent {...defaultProps} testID="example-component" />);
const { getByTestId } = render(
<ExampleComponent {...defaultProps} testID="example-component" />
);
expect(getByTestId('example-component')).toBeTruthy();
});
@ -78,7 +80,9 @@ describe('ExampleComponent', () => {
});
it('should call onLongPress when long pressed', () => {
const { getByText } = render(<ExampleComponent {...defaultProps} onLongPress={mockOnLongPress} />);
const { getByText } = render(
<ExampleComponent {...defaultProps} onLongPress={mockOnLongPress} />
);
fireEvent(getByText('Test Title'), 'onLongPress');
@ -242,7 +246,9 @@ describe('ExampleComponent', () => {
});
it('should handle undefined props gracefully', () => {
const { getByText } = render(<ExampleComponent title="Test" onPress={mockOnPress} description={undefined} />);
const { getByText } = render(
<ExampleComponent title="Test" onPress={mockOnPress} description={undefined} />
);
expect(getByText('Test')).toBeTruthy();
});

View file

@ -72,7 +72,10 @@ describe('authService', () => {
// Verify tokens were stored
expect(SecureStore.setItemAsync).toHaveBeenCalledWith('@auth/appToken', mockTokens.appToken);
expect(SecureStore.setItemAsync).toHaveBeenCalledWith('@auth/refreshToken', mockTokens.refreshToken);
expect(SecureStore.setItemAsync).toHaveBeenCalledWith(
'@auth/refreshToken',
mockTokens.refreshToken
);
});
it('should handle invalid credentials error', async () => {