@@ -33,6 +33,9 @@ vi.mock('$lib/utils/task', () => ({
3333
3434describe ( 'ContestTableProviderBase and implementations' , ( ) => {
3535 const mockTaskResults : TaskResults = taskResultsForContestTableProvider ;
36+ const getContestRound = ( contestId : string ) : number => {
37+ return parseInt ( contestId . replace ( 'abc' , '' ) , 10 ) ;
38+ } ;
3639
3740 describe ( 'ABC latest 20 rounds provider' , ( ) => {
3841 test ( 'expects to filter tasks to include only ABC contests' , ( ) => {
@@ -50,7 +53,7 @@ describe('ContestTableProviderBase and implementations', () => {
5053 const filtered = provider . filter ( largeDataset ) ;
5154 const uniqueContests = new Set ( filtered . map ( ( task ) => task . contest_id ) ) ;
5255
53- expect ( uniqueContests . size ) . toBeLessThanOrEqual ( 20 ) ;
56+ expect ( uniqueContests . size ) . toBe ( 20 ) ;
5457 } ) ;
5558
5659 test ( 'expects to generate correct table structure' , ( ) => {
@@ -90,7 +93,7 @@ describe('ContestTableProviderBase and implementations', () => {
9093 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBeTruthy ( ) ;
9194 expect (
9295 filtered . every ( ( task ) => {
93- const round = parseInt ( task . contest_id . replace ( 'abc' , '' ) , 10 ) ;
96+ const round = getContestRound ( task . contest_id ) ;
9497 return round >= 319 && round <= 999 ;
9598 } ) ,
9699 ) . toBeTruthy ( ) ;
@@ -121,7 +124,7 @@ describe('ContestTableProviderBase and implementations', () => {
121124 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBeTruthy ( ) ;
122125 expect (
123126 filtered . every ( ( task ) => {
124- const round = parseInt ( task . contest_id . replace ( 'abc' , '' ) , 10 ) ;
127+ const round = getContestRound ( task . contest_id ) ;
125128 return round >= 212 && round <= 318 ;
126129 } ) ,
127130 ) . toBeTruthy ( ) ;
@@ -147,16 +150,10 @@ describe('ContestTableProviderBase and implementations', () => {
147150 describe ( 'Common provider functionality' , ( ) => {
148151 test ( 'expects to get contest round IDs correctly' , ( ) => {
149152 const provider = contestTableProviders . abcLatest20Rounds ;
150- const filtered = [
151- { contest_id : 'abc397' , task_id : 'a' , status_name : 'ac' } ,
152- { contest_id : 'abc319' , task_id : 'a' , status_name : 'ac' } ,
153- { contest_id : 'abc319' , task_id : 'b' , status_name : 'ac' } ,
154- { contest_id : 'abc319' , task_id : 'c' , status_name : 'ac' } ,
155- { contest_id : 'abc319' , task_id : 'e' , status_name : 'ac_with_editorial' } ,
156- { contest_id : 'abc319' , task_id : 'f' , status_name : 'wa' } ,
157- { contest_id : 'abc319' , task_id : 'g' , status_name : 'ns' } ,
158- { contest_id : 'abc318' , task_id : 'a' , status_name : 'ac' } ,
159- ] as TaskResults ;
153+ // Use a subset of the mock data that covers the relevant contest IDs
154+ const filtered = mockTaskResults . filter ( ( task ) =>
155+ [ 'abc397' , 'abc319' , 'abc318' ] . includes ( task . contest_id ) ,
156+ ) ;
160157
161158 const roundIds = provider . getContestRoundIds ( filtered ) ;
162159
@@ -165,21 +162,7 @@ describe('ContestTableProviderBase and implementations', () => {
165162
166163 test ( 'expects to get header IDs for tasks correctly' , ( ) => {
167164 const provider = contestTableProviders . abcLatest20Rounds ;
168- const filtered = [
169- { contest_id : 'abc319' , task_id : 'abc319_a' , task_table_index : 'A' , status_name : 'ac' } ,
170- { contest_id : 'abc319' , task_id : 'abc319_b' , task_table_index : 'B' , status_name : 'ac' } ,
171- { contest_id : 'abc319' , task_id : 'abc319_c' , task_table_index : 'C' , status_name : 'ac' } ,
172- { contest_id : 'abc319' , task_id : 'abc319_d' , task_table_index : 'D' , status_name : 'ac' } ,
173- {
174- contest_id : 'abc319' ,
175- task_id : 'abc319_e' ,
176- task_table_index : 'E' ,
177- status_name : 'ac_with_editorial' ,
178- } ,
179- { contest_id : 'abc319' , task_id : 'abc319_f' , task_table_index : 'F' , status_name : 'wa' } ,
180- { contest_id : 'abc319' , task_id : 'abc319_g' , task_table_index : 'G' , status_name : 'ns' } ,
181- ] as TaskResults ;
182-
165+ const filtered = mockTaskResults . filter ( ( task ) => task . contest_id === 'abc319' ) ;
183166 const headerIds = provider . getHeaderIdsForTask ( filtered ) ;
184167
185168 expect ( headerIds ) . toEqual ( [ 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' ] ) ;
0 commit comments