Skip to content

Commit

Permalink
WIP: test mandatory free
Browse files Browse the repository at this point in the history
  • Loading branch information
musoke committed May 3, 2023
1 parent 1145489 commit addb0a4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/data/csvtojson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ fs.createReadStream('./ice.csv')
.on('end', () => {
const data = JSON.stringify(iceGrades)
fs.writeFileSync('ice.json', data)
})

fs.createReadStream('./aid.csv')
.pipe(csv())
Expand Down
2 changes: 1 addition & 1 deletion src/scales/__tests__/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('AI', () => {
expect(score).toEqual(-1)
})

test('not aid scale', () => {
test('not AI scale', () => {
const score = AI.getScore('v11')
expect(console.warn).toHaveBeenCalledWith('Unexpected grade format: v11 for grade scale AI')
expect(score).toEqual(-1)
Expand Down
18 changes: 6 additions & 12 deletions src/scales/__tests__/aid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Aid } from '../../scales'
describe('Aid', () => {
describe('Get Score', () => {
describe('valid grade formats', () => {
// Check that no warnings are raised and that the score is not -1
// Don't check for correct values of score, that is separate
jest.spyOn(console, 'warn').mockImplementation()
beforeEach(() => {
jest.clearAllMocks()
Expand All @@ -27,6 +25,12 @@ describe('Aid', () => {
expect(console.warn).not.toHaveBeenCalled()
expect(score).not.toEqual(-1)
})

test.failing('mandatory free', () => {
const score = Aid.getScore('5.9 A0')
expect(console.warn).not.toHaveBeenCalled()
expect(score).not.toEqual(-1)
})
})

describe('invalid grade formats', () => {
Expand Down Expand Up @@ -119,15 +123,5 @@ describe('Aid', () => {
test('top of range', () => {
expect(Aid.getGrade(Infinity)).toBe('A5')
})

test('single score provided', () => {
expect(Aid.getGrade(34)).toBe('A5')
expect(Aid.getGrade(34.5)).toBe('A5')
})

test('range of scores provided', () => {
expect(Aid.getGrade([0.5, 2])).toBe('A0')
expect(Aid.getGrade([8, 13])).toBe('A2/A2+')
})
})
})
2 changes: 1 addition & 1 deletion src/scales/__tests__/wi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('WI', () => {
expect(score).toEqual(-1)
})

test('not aid scale', () => {
test('not WI scale', () => {
const score = WI.getScore('v11')
expect(console.warn).toHaveBeenCalledWith('Unexpected grade format: v11 for grade scale WI')
expect(score).toEqual(-1)
Expand Down

0 comments on commit addb0a4

Please sign in to comment.