Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Aid scale #268

Merged
merged 1 commit into from
Jun 29, 2023
Merged
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
8 changes: 4 additions & 4 deletions src/GradeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
tr: GradeScales.EWBANK,
alpine: GradeScales.YDS,
mixed: GradeScales.YDS,
aid: GradeScales.YDS,
aid: GradeScales.AID,
snow: GradeScales.YDS, // is this the same as alpine?
ice: GradeScales.WI
},
Expand All @@ -55,7 +55,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
tr: GradeScales.YDS,
alpine: GradeScales.YDS,
mixed: GradeScales.YDS,
aid: GradeScales.YDS,
aid: GradeScales.AID,
snow: GradeScales.YDS, // is this the same as alpine?
ice: GradeScales.WI
},
Expand All @@ -66,7 +66,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
tr: GradeScales.FRENCH,
alpine: GradeScales.FRENCH,
mixed: GradeScales.FRENCH,
aid: GradeScales.FRENCH,
aid: GradeScales.AID,
snow: GradeScales.FRENCH, // is this the same as alpine?
ice: GradeScales.WI
},
Expand All @@ -77,7 +77,7 @@ export const gradeContextToGradeScales: Partial<Record<GradeContexts, ClimbGrade
tr: GradeScales.FRENCH,
alpine: GradeScales.FRENCH,
mixed: GradeScales.FRENCH,
aid: GradeScales.FRENCH,
aid: GradeScales.AID,
snow: GradeScales.FRENCH, // SA does not have a whole lot of snow
ice: GradeScales.WI
}
Expand Down
35 changes: 35 additions & 0 deletions src/__tests__/gradeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ describe('Test grade utilities', () => {
yds: '5.9'
})

actual = createGradeObject('5.10a', sanitizeDisciplines({ trad: true }), context)
expect(actual).toEqual({
yds: '5.10a'
})

actual = createGradeObject('A1', sanitizeDisciplines({ aid: true }), context)
expect(actual).toEqual({
aid: 'A1'
})

actual = createGradeObject('C2+', sanitizeDisciplines({ aid: true }), context)
expect(actual).toEqual({
aid: 'C2+'
})

actual = createGradeObject('V4', sanitizeDisciplines({ bouldering: true }), context)
expect(actual).toEqual({
vscale: 'V4'
Expand Down Expand Up @@ -85,6 +100,16 @@ describe('Test grade utilities', () => {
ewbank: '5'
})

actual = createGradeObject('A2', sanitizeDisciplines({ aid: true }), context)
expect(actual).toEqual({
aid: 'A2'
})

actual = createGradeObject('C3+', sanitizeDisciplines({ aid: true }), context)
expect(actual).toEqual({
aid: 'C3+'
})

actual = createGradeObject('v11', sanitizeDisciplines({ bouldering: true }), context)
expect(actual).toEqual({
vscale: 'v11'
Expand All @@ -109,6 +134,16 @@ describe('Test grade utilities', () => {
french: '5a'
})

actual = createGradeObject('A2', sanitizeDisciplines({ aid: true }), context)
expect(actual).toEqual({
aid: 'A2'
})

actual = createGradeObject('C1', sanitizeDisciplines({ aid: true }), context)
expect(actual).toEqual({
aid: 'C1'
})

actual = createGradeObject('7c', sanitizeDisciplines({ bouldering: true }), context)
expect(actual).toEqual({
font: '7c'
Expand Down
24 changes: 23 additions & 1 deletion src/model/__tests__/MutableClimbDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ describe('Climb CRUD', () => {
disciplines: {
ice: true
}
},
{
name: 'Cool aid one',
disciplines: {
aid: true
}
}
]

Expand All @@ -61,6 +67,15 @@ describe('Climb CRUD', () => {
description: 'A local testpiece'
}

const newAidRoute: ClimbChangeInputType = {
name: 'Gnarly Aid',
disciplines: {
aid: true
},
description: 'certain death',
grade: 'A0'
}

const newBoulderProblem1: ClimbChangeInputType = {
name: 'Cool boulder 1',
disciplines: {
Expand Down Expand Up @@ -265,7 +280,8 @@ describe('Climb CRUD', () => {
{ ...newSportClimb1, grade: '17' }, // good sport grade
{ ...newSportClimb2, grade: '29/30', disciplines: { trad: true } }, // good trad and slash grade
{ ...newSportClimb2, grade: '5.9' }, // bad AU context grade
{ ...newIceRoute, grade: 'WI4+' } // good WI AU context grade
{ ...newIceRoute, grade: 'WI4+' }, // good WI AU context grade
{ ...newAidRoute, grade: 'A0' } // good aid grade
]

const newIDs = await climbs.addOrUpdateClimbs(
Expand Down Expand Up @@ -293,6 +309,12 @@ describe('Climb CRUD', () => {
expect(climb4?.type.trad).toBe(false)
expect(climb4?.type.bouldering).toBe(false)
expect(climb4?.type.ice).toBe(true)

const climb5 = await climbs.findOneClimbByMUUID(muid.from(newIDs[4]))
expect(climb5?.grades).toEqual({ aid: 'A0' })
expect(climb5?.type.sport).toBe(false)
expect(climb5?.type.trad).toBe(false)
expect(climb5?.type.aid).toBe(true)
}

{
Expand Down