-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix heroku error * fix import
- Loading branch information
Showing
9 changed files
with
29 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import request from 'supertest'; | ||
import { app } from '../app.js'; | ||
import dbConnection from '../helpers/dbConnection.js'; | ||
import { connect, disconnect } from '../helpers/dbConnection.js'; | ||
|
||
const userBody = { | ||
email: `[email protected]`, | ||
|
@@ -28,10 +28,10 @@ jest.mock('nodemailer', () => ({ | |
|
||
describe('auth endpoints', () => { | ||
beforeAll(async () => { | ||
await dbConnection.connect(); | ||
await connect(); | ||
}); | ||
afterAll(async () => { | ||
await dbConnection.disconnect(); | ||
await disconnect(); | ||
}); | ||
|
||
it('should allow a POST to /auth/register with correct data', async () => { | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
import * as productionDbConnection from './productionDbConnection.js'; | ||
import * as testDbConnection from './testDbConnection.js'; | ||
import mongoose from 'mongoose'; | ||
|
||
const dbConnection = | ||
process.env.NODE_ENV === 'test' ? testDbConnection : productionDbConnection; | ||
export const connect = async () => { | ||
try { | ||
await mongoose.connect(process.env.MONGO_URL, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
}); | ||
} catch (error) { | ||
console.log(error.message); | ||
} | ||
}; | ||
|
||
export default dbConnection; | ||
export const disconnect = () => { | ||
return mongoose.disconnect(); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
jest.mock('./helpers/dbConnection'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import request from 'supertest'; | ||
import { app } from '../app.js'; | ||
import { USER_ROLE } from '../constants.js'; | ||
import dbConnection from '../helpers/dbConnection.js'; | ||
import { connect, disconnect } from '../helpers/dbConnection.js'; | ||
|
||
const userBody = { | ||
email: `[email protected]`, | ||
|
@@ -60,13 +60,13 @@ jest.mock('nodemailer', () => ({ | |
|
||
describe('user endpoints', () => { | ||
beforeAll(async () => { | ||
await dbConnection.connect(); | ||
await connect(); | ||
await registerUsers(); | ||
await getUsersData(adminToken); | ||
}); | ||
|
||
afterAll(async () => { | ||
await dbConnection.disconnect(); | ||
await disconnect(); | ||
}); | ||
|
||
describe('admin user', () => { | ||
|