-
-
Notifications
You must be signed in to change notification settings - Fork 660
Expand file tree
/
Copy patherror-handling.spec.js
More file actions
29 lines (23 loc) · 917 Bytes
/
error-handling.spec.js
File metadata and controls
29 lines (23 loc) · 917 Bytes
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
import { describe, expect, test, xtest } from '@jest/globals';
import { processString } from './error-handling';
describe('Error Handling', () => {
xtest('throws TypeError if input is not a string', () => {
expect(() => processString(42)).toThrow(TypeError);
});
xtest('returns null if string is empty', () => {
expect(processString('')).toBeNull();
});
xtest('throws error if input is too short',() => {
expect(() => processString('short')).toThrow()
})
xtest('throws error if input is too long', () => {
const longString = 'a'.repeat(101);
expect(() => processString(longString)).toThrow()
})
xtest('throws error if input contains a mix of letters and numbers', () => {
expect(() => processString('abc123')).toThrow()
})
xtest('returns uppercase string if input is valid', () => {
expect(processString('hellotherefriend')).toBe('HELLOTHEREFRIEND');
});
});