Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

was added unit tests to auth service

YakovAkka086b6edf1f4
diff --git a/src/action-tokens/action-tokens.service.spec.ts b/src/action-tokens/action-tokens.service.spec.ts
index ea6584a3f..8867bb842 100644
--- a/src/action-tokens/action-tokens.service.spec.ts
+++ b/src/action-tokens/action-tokens.service.spec.ts
@@ -1,7 +1,8 @@
import { Test, TestingModule } from '@nestjs/testing'
import { getRepositoryToken } from '@nestjs/typeorm'
+import { User } from 'src/user/entities/user.entity'
import { Repository } from 'typeorm'
-import { ActionToken } from './action-token.entity'
+import { ActionToken, ActionTokenType } from './action-token.entity'
import { ActionTokensService } from './action-tokens.service'
describe('ActionTokensService', () => {
diff --git a/src/auth/auth.service.spec.ts b/src/auth/auth.service.spec.ts
index 36039b771..6eadd4658 100644
--- a/src/auth/auth.service.spec.ts
+++ b/src/auth/auth.service.spec.ts
@@ -4,8 +4,6 @@ import { AppLoggerService } from 'src/logger/logger.service'
import { User } from 'src/user/entities/user.entity'
import { UserService } from 'src/user/user.service'
import { Repository } from 'typeorm'
-import { AuthController } from './auth.controller'
-import { AuthModule } from './auth.module'
import { AuthService } from './auth.service'
describe('AuthService', () => {
@@ -30,10 +28,58 @@ describe('AuthService', () => {
repository = module.get<Repository<User>>(USER_REPOSITORY_TOKEN)
service = module.get<AuthService>(AuthService)
})
-
describe('root', () => {
it('should be defined', () => {
expect(service).toBeDefined()
})
+
+ it('should be defined', () => {
+ expect(repository).toBeDefined()
+ })
+
+ it('should be hashPassword function not null', () => {
+ let pass = 'Password'
+ expect(service.hashPassword(pass)).resolves.not.toBeNull()
+ })
+
+ it('should be get function not null', () => {
+ let hash = 'HASSSSSSS'
+ expect(service.get(hash)).resolves.not.toBeNull()
+ })
+
+ it('should be sha1hash function not null', () => {
+ let string = 'string'
+ expect(service.sha1hash(string)).resolves.not.toBeNull()
+ })
+ it('should be checkIfPasswordLeaked function not null', () => {
+ let pass = 'password'
+ expect(service.checkIfPasswordLeaked(pass)).resolves.not.toBeNull()
+ })
+ it('should be checkPassword function not null', () => {
+ let passToCheck = 'test Password'
+ let hashedPass = 'hash Password'
+ expect(service.checkPassword(passToCheck, hashedPass)).not.toBeNull()
+ })
+
+ it('should be validateUser function not null', () => {
+ let email = 'email'
+ let pass = 'password'
+ expect(service.validateUser(email, pass)).rejects.toThrow()
+ })
+
+ it('should be processUser function not null', () => {
+ let user = new User()
+ expect(service.processUser(user)).not.toBeNull()
+ })
+
+ it('should be postLoginProcess function not null', () => {
+ let user = new User()
+ expect(service.postLoginProcess(user)).not.toBeNull()
+ })
+
+ it('should be login function not null', () => {
+ let user = new User()
+ expect(service.login(user)).not.toBeNull()
+ })
})
})