-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
29 lines (22 loc) · 1.03 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const validateMedicareNumber = require('./index');
test('throws if the Medicard card number is not provided', () => {
expect(() => validateMedicareNumber()).toThrowError();
});
test('throws if the Medicard card number is not a string', () => {
expect(() => validateMedicareNumber(123)).toThrowError();
});
test('returns false for an invalid Medicare card number (has alphabetic character)', () => {
expect(validateMedicareNumber('95050739A')).toBeFalsy();
});
test('returns false for an invalid Medicare card number (length not equal to 10)', () => {
expect(validateMedicareNumber('695050739')).toBeFalsy();
});
test('returns false for an invalid Medicare card number (incorrect check digit)', () => {
expect(validateMedicareNumber('6950507381')).toBeFalsy();
});
test('returns false for an invalid Medicare card number (last digit is zero)', () => {
expect(validateMedicareNumber('6950507380')).toBeFalsy();
});
test('returns true for a valid Medicare card number', () => {
expect(validateMedicareNumber('6950507391')).toBeTruthy();
});