Skip to content

Commit

Permalink
expand regex to parse / grades
Browse files Browse the repository at this point in the history
  • Loading branch information
Agilulfo committed Oct 7, 2024
1 parent 0889500 commit 9b1020c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/__tests__/scales/polish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
import { Polish } from '../../scales'

describe('Polish', () => {
describe('isPolish', () => {
describe('isType', () => {
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)
})
test('VI+/VI.1 is a valid slash grade', () => {
expect(Polish.isType('VI+/VI.1')).toBe(true)
})
test('VI+/VI.1+ is not a valid slash grade', () => {

Check failure on line 15 in src/__tests__/scales/polish.ts

View workflow job for this annotation

GitHub Actions / Tests annotations (🧪 jest-coverage-report-action)

Polish > isType > VI+/VI.1+ is not a valid slash grade

Error: expect(received).toBe(expected) // Object.is equality Expected: false Received: true at Object.<anonymous> (/home/runner/work/sandbag/sandbag/src/__tests__/scales/polish.ts:16:41) at Promise.then.completed (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/utils.js:293:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/utils.js:226:10) at _callCircusTest (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/run.js:297:40) at processTicksAndRejections (node:internal/process/task_queues:95:5) at _runTest (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/run.js:233:3) at _runTestsForDescribeBlock (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/run.js:135:9) at _runTestsForDescribeBlock (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/run.js:130:9) at _runTestsForDescribeBlock (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/run.js:130:9) at run (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/run.js:68:3) at runAndTransformResultsToJestFormat (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/sandbag/sandbag/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/sandbag/sandbag/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/sandbag/sandbag/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/sandbag/sandbag/node_modules/jest-runner/build/testWorker.js:106:12)
expect(Polish.isType('VI+/VI.1')).toBe(false)
})
})
// describe('Get Score', () => {
// test('9a > 5c', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/scales/polish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import routes from '../data/routes.json'
import { Route } from '.'
import { GradeBandTypes, routeScoreToBand } from '../GradeBands'

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

const PolishScale: GradeScale = {
Expand Down

0 comments on commit 9b1020c

Please sign in to comment.