diff --git a/src/__tests__/scales/polish.ts b/src/__tests__/scales/polish.ts index eaa38a2..af423cc 100644 --- a/src/__tests__/scales/polish.ts +++ b/src/__tests__/scales/polish.ts @@ -3,8 +3,11 @@ import { Polish } from '../../scales' describe('Polish', () => { describe('isPolish', () => { - test('VI', () => { - expect(Polish.isType('VI')) + test('VI is a valid grade', () => { + expect(Polish.isType('VI')).toBe(true) + }) + test('asd is not a valid grade', () => { + expect(Polish.isType('asd')).toBe(false) }) }) // describe('Get Score', () => { diff --git a/src/scales/polish.ts b/src/scales/polish.ts index 7dc1f79..a8d8e87 100644 --- a/src/scales/polish.ts +++ b/src/scales/polish.ts @@ -3,11 +3,7 @@ import routes from '../data/routes.json' import { Route } from '.' import { GradeBandTypes, routeScoreToBand } from '../GradeBands' -// TODO: set this regexp -const polishGradeRegex = /^([1-9][a-c][+]?){1}(?:(\/)([1-9][a-c][+]?))?$/i -// Supports 1a -> 9c+, slash grades i.e. 5a/5a+ or 6a+/6b -// NOTE: this currently assumes "incorrect" slash grades follows the normal pattern -// i.e. 6b+/5a => 6b+/6c +const polishGradeRegex = /^((I{1,3})|(IV\+?)|(V[+,-]?)|(VI(.[1-9])?\+?))?$/i const isPolish = (grade: string): RegExpMatchArray | null => grade.match(polishGradeRegex) const PolishScale: GradeScale = {