Skip to content

Commit

Permalink
test: Improve coverage for Saxon Scales.
Browse files Browse the repository at this point in the history
  • Loading branch information
marinojoey committed Sep 1, 2023
1 parent d5c4170 commit d0b6d64
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": false,
"source.fixAll.eslint": false
}
}
43 changes: 43 additions & 0 deletions src/scales/__tests__/saxon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Saxon as SaxonScale } from '../../scales'

describe('SAXON', () => {
describe('valid grade formats', () => {
let consoleWarnSpy

beforeEach(() => {
consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation()
})

afterEach(() => {
consoleWarnSpy.mockRestore()
})

test('should handle valid grade format "1"', () => {
const score = SaxonScale.getScore('1')
expect(console.warn).not.toHaveBeenCalled()
expect(score).not.toEqual(-1)
})
})

describe('isType', () => {
test('should return true for valid grade format "7a"', () => {
const isValid = SaxonScale.isType('7a')
expect(isValid).toBe(true)
})

test('should return true for valid grade format "1"', () => {
const isValid = SaxonScale.isType('1')
expect(isValid).toBe(true)
})

test('should return false for invalid grade format "V"', () => {
const isValid = SaxonScale.isType('V')
expect(isValid).toBe(false)
})

test('should return false for invalid grade format "8d"', () => {
const isValid = SaxonScale.isType('8d')
expect(isValid).toBe(false)
})
})
})

0 comments on commit d0b6d64

Please sign in to comment.