@@ -10,19 +10,9 @@ import {
1010 ABC042ToABC125Provider ,
1111 ABC001ToABC041Provider ,
1212} from './abc_providers' ;
13+ import { parseContestRound } from './contest_table_provider_base' ;
1314import { taskResultsForContestTableProvider } from '$features/tasks/fixtures/contest-table/contest_table_provider' ;
1415
15- const getContestRound = ( contestId : string ) : number => {
16- const roundString = contestId . replace ( / ^ \D + / , '' ) ;
17- const round = parseInt ( roundString , 10 ) ;
18-
19- if ( isNaN ( round ) ) {
20- throw new Error ( `Invalid contest ID format: ${ contestId } ` ) ;
21- }
22-
23- return round ;
24- } ;
25-
2616describe ( 'ABC providers' , ( ) => {
2717 const mockTaskResults : TaskResults = taskResultsForContestTableProvider ;
2818
@@ -116,7 +106,7 @@ describe('ABC providers', () => {
116106 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBe ( true ) ;
117107 expect (
118108 filtered . every ( ( task ) => {
119- const round = getContestRound ( task . contest_id ) ;
109+ const round = parseContestRound ( task . contest_id , 'abc' ) ;
120110 return round >= 319 && round <= 999 ;
121111 } ) ,
122112 ) . toBe ( true ) ;
@@ -143,7 +133,7 @@ describe('ABC providers', () => {
143133 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBe ( true ) ;
144134 expect (
145135 filtered . every ( ( task ) => {
146- const round = getContestRound ( task . contest_id ) ;
136+ const round = parseContestRound ( task . contest_id , 'abc' ) ;
147137 return round >= 319 ;
148138 } ) ,
149139 ) . toBe ( true ) ;
@@ -159,7 +149,7 @@ describe('ABC providers', () => {
159149 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBe ( true ) ;
160150 expect (
161151 filtered . every ( ( task ) => {
162- const round = getContestRound ( task . contest_id ) ;
152+ const round = parseContestRound ( task . contest_id , 'abc' ) ;
163153 return round >= 212 && round <= 318 ;
164154 } ) ,
165155 ) . toBe ( true ) ;
@@ -187,7 +177,7 @@ describe('ABC providers', () => {
187177 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBe ( true ) ;
188178 expect (
189179 filtered . every ( ( task ) => {
190- const round = getContestRound ( task . contest_id ) ;
180+ const round = parseContestRound ( task . contest_id , 'abc' ) ;
191181 return round >= 212 && round <= 318 ;
192182 } ) ,
193183 ) . toBe ( true ) ;
@@ -203,7 +193,7 @@ describe('ABC providers', () => {
203193 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBe ( true ) ;
204194 expect (
205195 filtered . every ( ( task ) => {
206- const round = getContestRound ( task . contest_id ) ;
196+ const round = parseContestRound ( task . contest_id , 'abc' ) ;
207197 return round >= 126 && round <= 211 ;
208198 } ) ,
209199 ) . toBe ( true ) ;
@@ -241,7 +231,7 @@ describe('ABC providers', () => {
241231 expect ( filtered . every ( ( task ) => task . contest_id . startsWith ( 'abc' ) ) ) . toBe ( true ) ;
242232 expect (
243233 filtered . every ( ( task ) => {
244- const round = getContestRound ( task . contest_id ) ;
234+ const round = parseContestRound ( task . contest_id , 'abc' ) ;
245235 return round >= 126 && round <= 211 ;
246236 } ) ,
247237 ) . toBe ( true ) ;
0 commit comments