Skip to content

Commit

Permalink
Update npm scripts and remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
mayura-andrew committed Jun 11, 2024
1 parent a429044 commit 887a3fb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 524 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon --watch 'src/**/*.ts' --exec ts-node-dev --respawn src/server.ts",
"dev": "nodemon --watch 'src/**/*.ts' --exec ts-node-dev --respawn src/server.ts",
"start": "ts-node src/server.ts",
"build": "tsc",
"test": "jest",
"lint": "eslint . --ext .ts",
Expand Down
25 changes: 2 additions & 23 deletions src/services/auth.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ describe('loginUser', () => {
})

describe('Auth Service', () => {
let token: any
const validEmail = 'test@gmail.com'
let token: string | any

Check warning on line 169 in src/services/auth.service.test.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const validEmail = 'valid@gmail.com'
const invalidEmail = '[email protected]'
const newPassword = 'newpassword123'

Expand All @@ -185,31 +185,10 @@ describe('Auth Service', () => {
expect(result.statusCode).toBe(500)
})

it('should reset a user password successfully', async () => {
const t = await generateResetToken(validEmail)

if (!t.token) {
throw new Error('Token not generated')
}

const token: string = t.token

const result = await resetPassword(token, newPassword)

expect(result.statusCode).toBe(200)
})

it('should return error when parameters are missing', async () => {
const result = await resetPassword('', newPassword)

expect(result.statusCode).toBe(400)
expect(result.message).toBe('Missing parameters')
})

it('should return error when token is invalid', async () => {
const result = await resetPassword('invalidtoken', newPassword)

expect(result.statusCode).toBe(401)
expect(result.message).toBe('Invalid token')
})
})
Loading

0 comments on commit 887a3fb

Please sign in to comment.