-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathindex.test.ts
More file actions
39 lines (34 loc) · 1.04 KB
/
index.test.ts
File metadata and controls
39 lines (34 loc) · 1.04 KB
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
30
31
32
33
34
35
36
37
38
39
// Uncomment the code below and write your tests
import {
resolveValue,
throwError,
throwCustomError,
rejectCustomError,
MyAwesomeError,
} from './index';
describe('resolveValue', () => {
test('should resolve the provided value', async () => {
await expect(resolveValue(42)).resolves.toBe(42);
const obj = { a: 1 };
await expect(resolveValue(obj)).resolves.toBe(obj);
});
});
describe('throwError', () => {
test('should throw error with provided message', () => {
const message = 'Boom!';
expect(() => throwError(message)).toThrow(message);
});
test('should throw error with default message if none provided', () => {
expect(() => throwError()).toThrow('Oops!');
});
});
describe('throwCustomError', () => {
test('should throw MyAwesomeError', () => {
expect(() => throwCustomError()).toThrow(MyAwesomeError);
});
});
describe('rejectCustomError', () => {
test('should reject with MyAwesomeError', async () => {
await expect(rejectCustomError()).rejects.toBeInstanceOf(MyAwesomeError);
});
});