Skip to content

Commit becb958

Browse files
committed
expand regex to parse / grades
1 parent 4234993 commit becb958

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/__tests__/scales/polish.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
import { Polish } from '../../scales'
33

44
describe('Polish', () => {
5-
describe('isPolish', () => {
5+
describe('isType', () => {
66
test('VI is a valid grade', () => {
77
expect(Polish.isType('VI')).toBe(true)
88
})
99
test('asd is not a valid grade', () => {
1010
expect(Polish.isType('asd')).toBe(false)
1111
})
12+
test('VI+/VI.1 is a valid slash grade', () => {
13+
expect(Polish.isType('VI+/VI.1')).toBe(true)
14+
})
15+
test('VI+/VI.1+ is not a valid slash grade', () => {
16+
expect(Polish.isType('VI+/VI.1')).toBe(false)
17+
})
1218
})
1319
// describe('Get Score', () => {
1420
// test('9a > 5c', () => {

src/scales/polish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import routes from '../data/routes.json'
33
import { Route } from '.'
44
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'
55

6-
const polishGradeRegex = /^((I{1,3})|(IV\+?)|(V[+,-]?)|(VI(.[1-9])?\+?))?$/i
6+
const polishGradeRegex = /^((?:I{1,3})|(?:IV[+]?)|(?:V[+,-]?)|(?:VI(?:\.[1-9])?[+]?)){1}(?:(\/)((?:I{1,3})|(?:IV[+]?)|(?:V[+,-]?)|(?:VI(?:\.[1-9])?[+]?)))?$/i
77
const isPolish = (grade: string): RegExpMatchArray | null => grade.match(polishGradeRegex)
88

99
const PolishScale: GradeScale = {

0 commit comments

Comments
 (0)