File tree Expand file tree Collapse file tree 4 files changed +12
-30
lines changed Expand file tree Collapse file tree 4 files changed +12
-30
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ node_modules
5
5
package-lock.json
6
6
* tempCodeRunnerFile.js
7
7
/coverage
8
+ OOP.js
8
9
#
9
10
# Optional npm cache directory
10
11
.npm
Original file line number Diff line number Diff line change
1
+ const fetch = require ( "node-fetch" )
1
2
//Takes a username as an argument and makes a call to GitHub API
2
3
//and returns all the repositoriesowned by the user as an array.
3
4
@@ -8,7 +9,7 @@ async function showGitHubRepos(handle) {
8
9
9
10
return repos . map ( repo => repo . name ) ;
10
11
}
11
- // showGitHubRepos("whiteh").then(data => console.log(data));
12
+ showGitHubRepos ( "whiteh" ) . then ( data => console . log ( data ) ) ;
12
13
13
14
const myrepo = [
14
15
"Ball-Bouncing-and-Collision" ,
Original file line number Diff line number Diff line change 1
- let showGitHubRepos = require ( "./getRepo" )
2
1
3
- describe ( "Mock testing showGitHubRepos implementation" , ( ) => {
4
- it ( "Test user with repositories" , async ( ) => {
5
- showGitHubRepos = jest
6
- . fn ( )
7
- . mockResolvedValue ( [
8
- "Ball-Bouncing-and-Collision" ,
9
- "css-grid" ,
10
- "CSS-Grid-Calculator" ,
11
- "CSS-Grid-Phone" ,
12
- "css-protips" ,
13
- "Databaseless-API"
14
- ] ) ;
15
2
16
- let repos = await showGitHubRepos ( ) . then ( data => data ) ;
17
3
18
- expect ( showGitHubRepos ) . toHaveBeenCalled ( ) ;
4
+ describe ( "Mock testing getRepo implementation" , ( ) => {
5
+ it ( "Make sure fetchRepo function is called" , async ( ) => {
6
+ let repos = await showGitHubRepos ( "iKnowJavaScript" ) ;
7
+
19
8
expect ( repos ) . toContain ( "CSS-Grid-Phone" ) ;
20
9
} ) ;
21
10
it ( "Should return 'User has not repository yet' if it return an empty array" , async ( ) => {
22
- showGitHubRepos = jest . fn ( ) . mockResolvedValue ( [ ] ) ;
23
-
24
- let repos = await showGitHubRepos ( ) . then ( data => data ) ;
11
+ let repos = await showGitHubRepos ( "rasaki" ) ;
25
12
26
- expect ( showGitHubRepos ) . toHaveBeenCalled ( ) ;
27
13
expect ( repos ) . toEqual ( [ ] ) ;
28
14
} ) ;
29
- // it("Should return 'User not found' if no array was returned", async () => {
30
- // showGitHubRepos = jest.fn().mockRejectedValue(new Error("User Not Found"));
31
-
32
- // const error = await showGitHubRepos();
33
-
34
- // expect(showGitHubRepos).toHaveBeenCalled();
35
- // expect(error).toMatch(/Not Found/);
36
- // });
37
- } ) ;
38
-
15
+ } ) ;
Original file line number Diff line number Diff line change 19
19
"homepage" : " https://github.com/iKnowJavaScript/tdd-with-jest#readme" ,
20
20
"devDependencies" : {
21
21
"jest" : " ^24.7.1"
22
+ },
23
+ "dependencies" : {
24
+ "nodemon" : " ^1.18.11"
22
25
}
23
26
}
You can’t perform that action at this time.
0 commit comments