Skip to content

Commit 933371d

Browse files
authored
fix: update weekly test expectations to match Sunday as week start (#405)
The weekly usage tests were expecting Thursday as the week start, but the implementation uses Sunday as the default week start. Updated all test expectations to match Sunday week start: - Single week test: adjusted dates to ensure they fall within same week - Multi-week tests: updated expected week start dates - Date filter test: corrected expected week for February data
1 parent f20bd39 commit 933371d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/data-loader.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ invalid json line
20642064
// Should be sorted by week descending (2024-01-15 first)
20652065
expect(result).toHaveLength(2);
20662066
expect(result[0]).toEqual({
2067-
week: '2024-01-11',
2067+
week: '2024-01-14',
20682068
inputTokens: 150,
20692069
outputTokens: 75,
20702070
cacheCreationTokens: 0,
@@ -2081,7 +2081,7 @@ invalid json line
20812081
}],
20822082
});
20832083
expect(result[1]).toEqual({
2084-
week: '2023-12-28',
2084+
week: '2023-12-31',
20852085
inputTokens: 300,
20862086
outputTokens: 150,
20872087
cacheCreationTokens: 0,
@@ -2111,12 +2111,12 @@ invalid json line
21112111
it('handles single week data', async () => {
21122112
const mockData: UsageData[] = [
21132113
{
2114-
timestamp: createISOTimestamp('2023-12-28T12:00:00Z'),
2114+
timestamp: createISOTimestamp('2024-01-01T12:00:00Z'),
21152115
message: { usage: { input_tokens: 100, output_tokens: 50 } },
21162116
costUSD: 0.01,
21172117
},
21182118
{
2119-
timestamp: createISOTimestamp('2024-01-02T12:00:00Z'),
2119+
timestamp: createISOTimestamp('2024-01-03T12:00:00Z'),
21202120
message: { usage: { input_tokens: 200, output_tokens: 100 } },
21212121
costUSD: 0.02,
21222122
},
@@ -2136,7 +2136,7 @@ invalid json line
21362136

21372137
expect(result).toHaveLength(1);
21382138
expect(result[0]).toEqual({
2139-
week: '2023-12-28',
2139+
week: '2023-12-31',
21402140
inputTokens: 300,
21412141
outputTokens: 150,
21422142
cacheCreationTokens: 0,
@@ -2191,7 +2191,7 @@ invalid json line
21912191
const result = await loadWeeklyUsageData({ claudePath: fixture.path });
21922192
const weeks = result.map(r => r.week);
21932193

2194-
expect(weeks).toEqual(['2024-01-18', '2024-01-11', '2024-01-04', '2023-12-28']);
2194+
expect(weeks).toEqual(['2024-01-21', '2024-01-14', '2024-01-07', '2023-12-31']);
21952195
});
21962196

21972197
it('sorts weeks in ascending order when order is \'asc\'', async () => {
@@ -2231,7 +2231,7 @@ invalid json line
22312231
const result = await loadWeeklyUsageData({ claudePath: fixture.path, order: 'asc' });
22322232
const weeks = result.map(r => r.week);
22332233

2234-
expect(weeks).toEqual(['2023-12-28', '2024-01-04', '2024-01-11', '2024-01-18']);
2234+
expect(weeks).toEqual(['2023-12-31', '2024-01-07', '2024-01-14', '2024-01-21']);
22352235
});
22362236

22372237
it('handles year boundaries correctly in sorting', async () => {
@@ -2274,15 +2274,15 @@ invalid json line
22742274
order: 'desc',
22752275
});
22762276
const descWeeks = descResult.map(r => r.week);
2277-
expect(descWeeks).toEqual(['2024-02-01', '2023-12-28', '2023-11-30', '2023-11-02']);
2277+
expect(descWeeks).toEqual(['2024-02-04', '2023-12-31', '2023-12-03', '2023-11-05']);
22782278

22792279
// Ascending order
22802280
const ascResult = await loadWeeklyUsageData({
22812281
claudePath: fixture.path,
22822282
order: 'asc',
22832283
});
22842284
const ascWeeks = ascResult.map(r => r.week);
2285-
expect(ascWeeks).toEqual(['2023-11-02', '2023-11-30', '2023-12-28', '2024-02-01']);
2285+
expect(ascWeeks).toEqual(['2023-11-05', '2023-12-03', '2023-12-31', '2024-02-04']);
22862286
});
22872287

22882288
it('respects date filters', async () => {
@@ -2322,7 +2322,7 @@ invalid json line
23222322

23232323
// Should only include February data
23242324
expect(result).toHaveLength(1);
2325-
expect(result[0]?.week).toBe('2024-02-01');
2325+
expect(result[0]?.week).toBe('2024-02-04');
23262326
expect(result[0]?.inputTokens).toBe(200);
23272327
});
23282328

0 commit comments

Comments
 (0)