-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.test.js
More file actions
36 lines (30 loc) · 846 Bytes
/
Copy pathfunctions.test.js
File metadata and controls
36 lines (30 loc) · 846 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
30
31
32
33
34
35
36
const functions = require('./functions');
// toBe
test('Adds 2 + 2 to equal 4', () => {
expect(functions.add(2, 2)).toBe(4);
});
// not
test('Adds 2 + 2 to NOT equal 5', () => {
expect(functions.add(2, 2)).not.toBe(5);
});
// check for truthy and falsy values
// toBeNull matches only null
// toBeUndefined matches only undefined
// toBeDefined is the opposite of toBeUndefined
// toBeTruthy matches truthy expressions
// toBeFalsy matches falsy expressions
// toBeNull
test('Should be null', () => {
expect(functions.isNull()).toBeNull();
});
// toBeFalsy
test('Should be falsy', () => {
expect(functions.checkValue(undefined)).toBeFalsy();
});
// toEqual
test('User should be Brad Traversy object', () => {
expect(functions.createUser()).toEqual({
firstName: 'Brad',
lastName: 'Traversy'
});
});