-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.test.js
More file actions
35 lines (27 loc) · 1.02 KB
/
script.test.js
File metadata and controls
35 lines (27 loc) · 1.02 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
const googleSearch = require('./script');
dbMock = [
'dog.com',
'cheesepuff.com',
'dogpictures.com'
];
// Group similar test together using the Describe
describe ('googleSearch', () => {
it('Is a silly test', ()=>{
expect('hello').toBe('hello')
})
// Testing the search google function
it('is searching google', () => {
expect(googleSearch('test', dbMock)).toEqual([]);
expect(googleSearch('dog', dbMock)).toEqual(['dog.com', 'dogpictures.com']);
})
// Test that the function logic works with undefined and null inputs
it('work with undefined and null input', () => {
expect(googleSearch(undefined, dbMock)).toEqual([]);
expect(googleSearch(null, dbMock)).toEqual([]);
})
// Testing that our search does not return more than 3 matches
it('It does not return more than 3 matches', () => {
expect(googleSearch('.com', dbMock).length).toEqual(3);
// expect(googleSearch(null, dbMock)).toEqual([])
})
})