Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,633 changes: 17,633 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/GradeBands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const boulderScoreToBand = (score: number): GradeBandTypes => {
const distribution = {
[GradeBands.UNKNOWN]: -1,
[GradeBands.BEGINNER]: 0,
[GradeBands.INTERMEDIATE]: 50,
[GradeBands.ADVANCED]: 60,
[GradeBands.EXPERT]: 72
[GradeBands.INTERMEDIATE]: 24,
[GradeBands.ADVANCED]: 28,
[GradeBands.EXPERT]: 38
}
return scoreToBand(score, distribution)
}
6 changes: 3 additions & 3 deletions src/__tests__/GradeBands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe('GradeBands', () => {
test('returns grade bands based on scores for a bouldering distribution', () => {
expect(boulderScoreToBand(-1)).toEqual(GradeBands.UNKNOWN)
expect(boulderScoreToBand(0)).toEqual(GradeBands.BEGINNER)
expect(boulderScoreToBand(50)).toEqual(GradeBands.INTERMEDIATE)
expect(boulderScoreToBand(60)).toEqual(GradeBands.ADVANCED)
expect(boulderScoreToBand(72)).toEqual(GradeBands.EXPERT)
expect(boulderScoreToBand(24)).toEqual(GradeBands.INTERMEDIATE)
expect(boulderScoreToBand(28)).toEqual(GradeBands.ADVANCED)
expect(boulderScoreToBand(38)).toEqual(GradeBands.EXPERT)
})
})
30 changes: 15 additions & 15 deletions src/__tests__/GradeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,27 @@ describe('Grade Scales', () => {
})

describe('FONT', () => {
test('2a > 1a', () => {
expect(getScoreForSort('2a', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('1a', GradeScales.FONT)
test('2 > 1', () => {
expect(getScoreForSort('2', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('1', GradeScales.FONT)
)
})

test('2a+ > 2a', () => {
expect(getScoreForSort('2a+', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('2a', GradeScales.FONT)
test('2+ > 2', () => {
expect(getScoreForSort('2+', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('2', GradeScales.FONT)
)
})

test('3a/3a+ > 3a', () => {
expect(getScoreForSort('3a/3a+', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('3a', GradeScales.FONT)
test('3/3+ > 3', () => {
expect(getScoreForSort('3/3+', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('3', GradeScales.FONT)
)
})

test('4a > 3a+/4a', () => {
expect(getScoreForSort('4a', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('3a+/4a', GradeScales.FONT)
test('4 > 3+/4', () => {
expect(getScoreForSort('4', GradeScales.FONT)).toBeGreaterThan(
getScoreForSort('3+/4', GradeScales.FONT)
)
})

Expand All @@ -135,11 +135,11 @@ describe('Grade Scales', () => {
})

test('convert FONT to VSCALE', () => {
expect(convertGrade('3a', GradeScales.FONT, GradeScales.VSCALE)).toEqual('VB+')
expect(convertGrade('3', GradeScales.FONT, GradeScales.VSCALE)).toEqual('VB')
})

test('convert FONT to YDS is not allowed', () => {
expect(convertGrade('3a', GradeScales.FONT, GradeScales.YDS)).toEqual('')
expect(convertGrade('3', GradeScales.FONT, GradeScales.YDS)).toEqual('')
expect(console.warn).toHaveBeenCalledWith(
expect.stringContaining(
"Scale: Fontainebleau doesn't support converting to Scale: Yosemite Decimal System"
Expand All @@ -148,7 +148,7 @@ describe('Grade Scales', () => {
})

test('convert FONT to FRENCH is not allowed', () => {
expect(convertGrade('3a', GradeScales.FONT, GradeScales.FRENCH)).toEqual('')
expect(convertGrade('3', GradeScales.FONT, GradeScales.FRENCH)).toEqual('')
expect(console.warn).toHaveBeenCalledWith(
expect.stringContaining(
"Scale: Fontainebleau doesn't support converting to Scale: French Scale"
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe('Convert grades to scores', () => {
})
})

describe('Convert scores to greades', () => {
describe('Convert scores to grades', () => {
test('supports single score', () => {
expect(Font.getGrade(80)).toEqual('7c')
expect(Font.getGrade(49)).toEqual('7c')
})
test('supports a range of scores', () => {
expect(Font.getGrade([79, 81])).toEqual('7b+/7c')
expect(Font.getGrade([47, 48])).toEqual('7b+/7c')
})
})

Expand Down
46 changes: 23 additions & 23 deletions src/__tests__/scales/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ import { Font } from '../../scales'

describe('Font', () => {
describe('Get Score', () => {
test('9a > 5c', () => {
const lowGrade = Font.getScore('5c')
test('9a > 5+', () => {
const lowGrade = Font.getScore('5+')
const highGrade = Font.getScore('9a')
expect(highGrade[0]).toBeGreaterThan(lowGrade[1])
})

test('1c > 1a+', () => {
const highGrade = Font.getScore('1c')
const lowGrade = Font.getScore('1a+')
test('1+ > 1', () => {
const highGrade = Font.getScore('1+')
const lowGrade = Font.getScore('1')
expect(highGrade[0]).toBeGreaterThan(lowGrade[1])
})

test('1a/1a+ > 1a, one grade away', () => {
const highGrade = Font.getScore('1a/1a+')
const lowGrade = Font.getScore('1a')
test('2/2+ > 1, one grade away', () => {
const highGrade = Font.getScore('2/2+')
const lowGrade = Font.getScore('1')
expect(highGrade[0] < lowGrade[1] && highGrade[0] > lowGrade[0])
expect(highGrade[1]).toBeGreaterThan(lowGrade[1])
})

test('4a > 3c+/4a, one grade away', () => {
const highGrade = Font.getScore('4a')
const lowGrade = Font.getScore('3c+/4a')
test('4 > 3+/4-, one grade away', () => {
const highGrade = Font.getScore('4')
const lowGrade = Font.getScore('3+/4-')
expect(highGrade[0] < lowGrade[1] && highGrade[0] > lowGrade[0])
expect(highGrade[1]).toBeGreaterThan(lowGrade[1])
})
Expand All @@ -45,14 +45,14 @@ describe('Font', () => {
expect(invalidGrade).toEqual(-1)
})
test('extra slash grade', () => {
const invalidGrade = Font.getScore('5a/5a+/5b+')
expect(console.warn).toHaveBeenCalledWith('Unexpected grade format: 5a/5a+/5b+ for grade scale font')
const invalidGrade = Font.getScore('5/5+/6-')
expect(console.warn).toHaveBeenCalledWith('Unexpected grade format: 5/5+/6- for grade scale font')

expect(invalidGrade).toEqual(-1)
})
test('extra slash', () => {
const invalidGrade = Font.getScore('5a/')
expect(console.warn).toHaveBeenCalledWith('Unexpected grade format: 5a/ for grade scale font')
const invalidGrade = Font.getScore('5+/')
expect(console.warn).toHaveBeenCalledWith('Unexpected grade format: 5+/ for grade scale font')

expect(invalidGrade).toEqual(-1)
})
Expand All @@ -67,28 +67,28 @@ describe('Font', () => {

describe('Get Grade', () => {
test('bottom of range', () => {
expect(Font.getGrade(0)).toBe('1a')
expect(Font.getGrade(0)).toBe('1')
})

test('top of range', () => {
expect(Font.getGrade(1000)).toBe('9c+')
})

test('single score provided', () => {
expect(Font.getGrade(34)).toBe('3c+')
expect(Font.getGrade(34.5)).toBe('3c+')
expect(Font.getGrade(35)).toBe('3c+')
expect(Font.getGrade(34)).toBe('6b+')
expect(Font.getGrade(34.5)).toBe('6b+')
expect(Font.getGrade(35)).toBe('6b+')
})
test('range of scores provided', () => {
expect(Font.getGrade([0.5, 2])).toBe('1a/1a+')
expect(Font.getGrade([8, 12])).toBe('1c/2a')
expect(Font.getGrade([16, 17])).toBe('2b')
expect(Font.getGrade([0.5, 2])).toBe('1/1+')
expect(Font.getGrade([8, 12])).toBe('2+/3')
expect(Font.getGrade([16, 17])).toBe('4-')
})
})

describe('Get Grade Band', () => {
test('gets Gradeband', () => {
expect(Font.getGradeBand('1a')).toEqual(GradeBands.BEGINNER)
expect(Font.getGradeBand('1')).toEqual(GradeBands.BEGINNER)
expect(Font.getGradeBand('9c+')).toEqual(GradeBands.EXPERT)
})
})
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/scales/v.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ describe('V', () => {
})

test('single score provided', () => {
expect(VScale.getGrade(62)).toBe('V3')
expect(VScale.getGrade(61)).toBe('V3')
expect(VScale.getGrade(63)).toBe('V4')
expect(VScale.getGrade(28)).toBe('V3')
expect(VScale.getGrade(33)).toBe('V4')
expect(VScale.getGrade(62)).toBe('V16')
})

test('range of scores provided', () => {
expect(VScale.getGrade([51, 56])).toBe('V1-V2')
expect(VScale.getGrade([77, 80])).toBe('V8-V9')
expect(VScale.getGrade([66, 72])).toBe('V4-V6')
expect(VScale.getGrade([20, 25])).toBe('V0+-V1')
expect(VScale.getGrade([51, 56])).toBe('V10-V13')
expect(VScale.getGrade([77, 80])).toBe('V22')
})
})

Expand Down
Loading