This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added null checks to Grades type and tests for it
- Loading branch information
1 parent
0470fc5
commit 46a8d3d
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Grades from '../../types/Grades'; | ||
import { Indexable, fetchMock } from '../util'; | ||
|
||
const correctArgs: Indexable = { | ||
gpa: 0.0, A: 0, B: 0, C: 0, D: 0, F: 0, I: 0, S: 0, Q: 0, X: 0, | ||
}; | ||
|
||
const createGrades = jest.fn((args) => new Grades(fetchMock(args))); | ||
|
||
describe('Grades type', () => { | ||
describe('throws an error', () => { | ||
const nonNullableProps = ['gpa', 'A', 'B', 'C', 'D', 'F', 'I', 'S', 'Q', 'X']; | ||
test.each(nonNullableProps)('when any of the properties are null %s', (prop) => { | ||
// arrange | ||
const badArgs = { ...correctArgs }; | ||
badArgs[prop] = null; | ||
|
||
// act/assert | ||
expect(() => createGrades(badArgs)).toThrow(); | ||
}); | ||
}); | ||
|
||
describe('does not throw an error', () => { | ||
test('when all of the props are not-null', () => { | ||
// arrange/act/assert | ||
expect(() => createGrades(correctArgs)).not.toThrow(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters