-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.test.js
51 lines (39 loc) · 1.14 KB
/
functions.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const functions = require('./functions');
test('ADD 2+2 = 4 ', () => {
expect(functions.add(2, 2)).toBe(4);
});
test('ADD 2+2 Not Equal 4 ', () => {
expect(functions.add(2, 2)).not.toBe(5);
});
test('IsNull ', () => {
expect(functions.isNulll()).toBe(null);
});
test('Should be falsy ', () => {
expect(functions.checkValue(0)).toBeFalsy();
//.not = toBetruthy
});
// toBe is not working on objects we use toEqual
test('Should be falsy ', () => {
expect(functions.createUser()).toEqual({ firstname: 'Abdelhedi', lastnaem: 'Hlel' });
});
// test Numbers
test('Should Be under 1600', () => {
const x = 800;
const y = 700;
expect(x + y).toBeLessThan(1600)
})
//Test Regex
test('There is no I in Team', () => {
expect('team').not.toMatch(/I/);
})
//Wroking with Arrays
test('Admin should be in usernames', () => {
const usernames = ['normal_user', 'super_user', 'admin'];
expect(usernames).toContain('admin')
})
// //Working with async data
// test('User fetched name should be Leanne Graham', async () => {
// // expect.assertions(1);
// const data = await functions.searchUser();
// expect(data.name).toEqual('Leanne Graham');
// })