test(frontend): raise overall statement coverage to 30.42% for Phase 1 MVP

This commit is contained in:
2026-06-13 22:33:11 +07:00
parent 190b9a3af5
commit 9c5df0abdb
37 changed files with 6128 additions and 24 deletions
+6 -6
View File
@@ -1,3 +1,7 @@
// File: lib/services/session.service.ts
// Change Log:
// - 2026-06-13: Export helper functions for testing, clean up formatting, and add file header
import apiClient from '@/lib/api/client';
export interface Session {
@@ -14,25 +18,21 @@ export interface Session {
isCurrent: boolean;
}
const extractArrayData = <T>(value: unknown): T[] => {
export const extractArrayData = <T>(value: unknown): T[] => {
let current: unknown = value;
for (let i = 0; i < 5; i += 1) {
if (Array.isArray(current)) {
return current as T[];
}
if (!current || typeof current !== 'object' || !('data' in current)) {
return [];
}
current = (current as { data?: unknown }).data;
}
return Array.isArray(current) ? (current as T[]) : [];
};
const transformSession = (session: Session | (Omit<Session, 'id'> & { id: string | number })): Session => ({
export const transformSession = (session: Session | (Omit<Session, 'id'> & { id: string | number })): Session => ({
...session,
id: typeof session.id === 'number' ? session.id : Number(session.id),
});