-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor import statement for User model to use lowercase filename, c…
…hanged index to app, cleaned up pacage.json
- Loading branch information
OomsOoms
committed
Jul 31, 2024
1 parent
4b24836
commit 2ee8b4d
Showing
9 changed files
with
473 additions
and
361 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const User = require('./User.model.js'); | ||
const User = require('./user.model.js'); | ||
|
||
module.exports = { | ||
User, | ||
|
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,7 +1,23 @@ | ||
const request = require('supertest'); | ||
const app = require('../../src/index'); | ||
const app = require('../../src/app'); | ||
const { User } = require('../../src/api/models'); | ||
const { generateJwt } = require('../../src/api/helpers'); | ||
const nodemailer = require('nodemailer'); | ||
|
||
let savedEmailText; | ||
jest.mock('nodemailer', () => { | ||
const nodemailerMock = { | ||
sendMail: jest.fn((mailOptions, callback) => { | ||
savedEmailText = mailOptions.text; // Capture the email text | ||
callback(null, { | ||
response: '250 Message accepted', | ||
}); | ||
}), | ||
}; | ||
return { | ||
createTransport: jest.fn(() => nodemailerMock), | ||
}; | ||
}) | ||
|
||
let token = ''; | ||
let user = null; | ||
|
@@ -53,6 +69,7 @@ describe('POST /api/users/verify', () => { | |
const response = await request(app) | ||
.post('/api/users/verify') | ||
.send({ email: '[email protected]' }); | ||
console.log(response.body); | ||
expect(response.status).toBe(200); | ||
expect(response.body.message).toBe('Verification email sent'); | ||
// should check if the email was sent? seems like effort though and if i write a unit test for the email function then i would be testing it twice | ||
|
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
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