Skip to content

Commit 2f3764e

Browse files
committed
Changing test folder structure
1 parent bd84578 commit 2f3764e

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const supertest = require('supertest');
2-
const { setupApp, closeApp } = require('../../src/app.js');
3-
const Github = require('../resources/github');
2+
const { setupApp, closeApp } = require('../../../src/app.js');
3+
const Github = require('../../resources/github');
44

5-
describe('Github resource without nock', () => {
5+
describe('Github resource with di', () => {
66
let request;
77
const githubResource = new Github();
88
beforeAll(async function() {
@@ -14,6 +14,7 @@ describe('Github resource without nock', () => {
1414

1515
describe('route /', () => {
1616
describe('when a GET request is done to / endpoint', () => {
17+
1718
test('should respond with the followers count', async() => {
1819
const fakeRequest = {
1920
get: () => Promise.resolve({data: { followers: 120 } })
@@ -23,6 +24,7 @@ describe('Github resource without nock', () => {
2324
const response = await request.get('/waldemarnt/followers');
2425
expect(response.body).toEqual({followers:120});
2526
});
27+
2628
test('should throw error when the user is not found', async() => {
2729
const fakeRequest = {
2830
get: () => Promise.reject({response: {data: 'Not Found', status: 404}})
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const supertest = require('supertest');
2-
const { setupApp, closeApp } = require('../../src/app.js');
2+
const { setupApp, closeApp } = require('../../../src/app.js');
33
const axios = require('axios');
44

55
jest.mock('axios');
66

7-
describe('Github resource without nock', () => {
7+
describe('Github resource with jest', () => {
88
let request;
99
beforeAll(async function() {
1010
const app = await setupApp();
@@ -15,12 +15,14 @@ describe('Github resource without nock', () => {
1515

1616
describe('route /', () => {
1717
describe('when a GET request is done to / endpoint', () => {
18+
1819
test('should respond with the followers count', async() => {
1920
axios.get.mockResolvedValue({data: { followers: 120 } });
2021

2122
const response = await request.get('/waldemarnt/followers');
2223
expect(response.body).toEqual({followers:120});
2324
});
25+
2426
test('should throw error when the user is not found', async() => {
2527
axios.get.mockRejectedValue({response: {data: 'Not Found', status: 404}});
2628

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const supertest = require('supertest');
2-
const { setupApp, closeApp } = require('../../src/app.js');
2+
const { setupApp, closeApp } = require('../../../src/app.js');
33
const nock = require('nock');
44

5-
describe('Github resource', () => {
5+
describe('Github resource with nock', () => {
66
let request;
77
beforeAll(async function() {
88
const app = await setupApp();
@@ -17,16 +17,19 @@ describe('Github resource', () => {
1717

1818
describe('route /', () => {
1919
describe('when a GET request is done to / endpoint', () => {
20+
2021
test('should respond with the followers count', async() => {
2122
nock('https://api.github.com')
2223
.defaultReplyHeaders({ 'access-control-allow-origin': '*' })
2324
.get('/users/waldemarnt')
2425
.reply(200, {
2526
followers: 120
2627
});
28+
2729
const response = await request.get('/waldemarnt/followers');
2830
expect(response.body).toEqual({followers:120});
2931
});
32+
3033
test('should throw error when the user is not found', async() => {
3134
nock('https://api.github.com')
3235
.defaultReplyHeaders({ 'access-control-allow-origin': '*' })

0 commit comments

Comments
 (0)