fix: improve test coverage accuracy and fix session timestamp bug
- Exclude seed files from coverage (not business logic) - Fix Date.now() double call bug in createSession functions - Coverage improved: 53.13% → 54.18% - All 122 test suites passing
This commit is contained in:
@@ -8,6 +8,7 @@ module.exports = {
|
|||||||
'!src/**/*.d.ts',
|
'!src/**/*.d.ts',
|
||||||
'!src/**/*.stories.{ts,tsx}',
|
'!src/**/*.stories.{ts,tsx}',
|
||||||
'!src/**/__tests__/**',
|
'!src/**/__tests__/**',
|
||||||
|
'!src/db/seed*.ts',
|
||||||
],
|
],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ export interface Session extends SessionData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createSession(userData: SessionData): Session {
|
export function createSession(userData: SessionData): Session {
|
||||||
|
const now = Date.now();
|
||||||
return {
|
return {
|
||||||
...userData,
|
...userData,
|
||||||
createdAt: Date.now(),
|
createdAt: now,
|
||||||
expiresAt: Date.now() + (24 * 60 * 60 * 1000),
|
expiresAt: now + (24 * 60 * 60 * 1000),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,9 +34,10 @@ export function isSessionExpired(session: Session): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createSessionWithCustomExpiration(userData: SessionData, expiresInMs: number): Session {
|
export function createSessionWithCustomExpiration(userData: SessionData, expiresInMs: number): Session {
|
||||||
|
const now = Date.now();
|
||||||
return {
|
return {
|
||||||
...userData,
|
...userData,
|
||||||
createdAt: Date.now(),
|
createdAt: now,
|
||||||
expiresAt: Date.now() + expiresInMs,
|
expiresAt: now + expiresInMs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user