-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17a4683
commit 2fb8b8b
Showing
17 changed files
with
17,105 additions
and
744 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { BlogController } from "./blog.controller"; | ||
import { BlogService } from "./blog.service"; | ||
|
||
describe('BlogController', () => { | ||
it('should be defined', () => { | ||
const service: BlogService = {} as BlogService; | ||
const controller = new BlogController(service); | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
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,78 @@ | ||
import { Repository } from 'typeorm'; | ||
import { BlogService } from './blog.service'; | ||
import { Blog } from './entities/blog.entity'; | ||
import { Comment } from '../comment/entities/comment.entity'; | ||
|
||
describe('BlogService', () => { | ||
let service: BlogService; | ||
let blogRepository: Repository<Blog>; | ||
const mockBlog: Blog = { | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
title: 'HowTo', | ||
slug: 'slugging', | ||
cover: 'got no image for this', | ||
content: 'how to content', | ||
comments: [], | ||
id: '3934cb36-4ad7-4eb0-a3f7-49ef7e81bb41', | ||
}; | ||
|
||
const mockBlog1: Blog = { | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
title: 'HowTo', | ||
slug: 'a generated slug', | ||
cover: 'got no image for this', | ||
content: 'how to content', | ||
comments: [], | ||
id: '3934cb36-4ad7-4eb0-a3f7-49ef7e81bb41', | ||
}; | ||
|
||
const comment: Comment = { | ||
fullname: 'John Doe', | ||
comment: 'test com', | ||
blog: mockBlog, | ||
id: '6c4deca1-8887-4bb4-b454-d34539c0af45', | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}; | ||
|
||
beforeEach(async () => { | ||
blogRepository = { | ||
create: jest.fn().mockReturnValue(mockBlog), | ||
save: jest.fn().mockReturnValue(mockBlog), | ||
findOne: jest.fn().mockReturnValue(mockBlog), | ||
find: jest.fn().mockReturnValue([mockBlog, mockBlog1]), | ||
createQueryBuilder: jest.fn().mockReturnValue({ | ||
leftJoinAndSelect: jest.fn().mockReturnThis(), | ||
where: jest.fn().mockReturnThis(), | ||
orderBy: jest.fn().mockReturnThis(), | ||
getOne: jest.fn().mockReturnThis(), | ||
}), | ||
} as unknown as Repository<Blog>; | ||
|
||
service = new BlogService(blogRepository); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it('should add a blog post', async () => { | ||
const result = await service.add(mockBlog); | ||
expect(result).toEqual(mockBlog); | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('should get all blog posts', async () => { | ||
const result = await service.getAll(); | ||
expect(result).toEqual([mockBlog, mockBlog1]); | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('should get blogs with comments', async () => { | ||
const result = await service.getBlogDetailsWithComments('slugging'); | ||
expect(result.last[0]).toEqual(mockBlog); | ||
expect(result).toBeDefined(); | ||
}); | ||
}); |
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,10 @@ | ||
import { CommentController } from "./comment.controller"; | ||
import { CommentService } from "./comment.service"; | ||
|
||
describe('CommentController', () => { | ||
it('should be defined', () => { | ||
const service: CommentService = {} as CommentService; | ||
const controller = new CommentController(service); | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
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,33 @@ | ||
import { Repository } from 'typeorm'; | ||
import { Comment } from './entities/comment.entity'; | ||
import { CommentService } from './comment.service'; | ||
import { Blog } from '../blog/entities/blog.entity'; | ||
import { CreateCommentDto } from './dto/comment.dto'; | ||
|
||
describe('CommentService', () => { | ||
let service: CommentService; | ||
let commentRepository: Repository<Comment>; | ||
let blogRepository: Repository<Blog>; | ||
const mockComment: CreateCommentDto = { | ||
fullname: 'testing the comments', | ||
comment: 'comment test', | ||
email: '[email protected]', | ||
blog: 'a random blog', | ||
}; | ||
|
||
beforeEach(async () => { | ||
commentRepository = { | ||
create: jest.fn().mockReturnValue(mockComment), | ||
save: jest.fn().mockReturnValue(mockComment), | ||
findOne: jest.fn().mockReturnValue(mockComment), | ||
createQueryBuilder: jest.fn().mockReturnValue({ | ||
}), | ||
} as unknown as Repository<Comment>; | ||
|
||
service = new CommentService(commentRepository, blogRepository); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
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,10 @@ | ||
import { ContactController } from './contact.controller'; | ||
import { ContactService } from './contact.service'; | ||
|
||
describe('ContactController', () => { | ||
it('should be defined', () => { | ||
const service: ContactService = {} as ContactService; | ||
const controller = new ContactController(service); | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
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,25 +1,24 @@ | ||
import { | ||
Body, | ||
Controller, | ||
Post | ||
} from '@nestjs/common'; | ||
import { ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { _403, _404, _409 } from '../../common/constants/errors'; | ||
Body, | ||
Controller, | ||
Post | ||
} from '@nestjs/common'; | ||
import { ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { _403, _404, _409 } from '../../common/constants/errors'; | ||
import { ContactService } from './contact.service'; | ||
import { Public } from 'src/common/decorators/public.decorator'; | ||
import { Public } from '../../common/decorators/public.decorator'; | ||
import { CreateContactDto } from './dto/contact.dto'; | ||
|
||
@ApiTags('Contacts') | ||
@Controller('contacts') | ||
export class ContactController { | ||
constructor(private readonly contactService: ContactService) {} | ||
|
||
@Post() | ||
@Public() | ||
@ApiOperation({ summary: 'Save contact information' }) | ||
async add(@Body() contactDto: CreateContactDto) { | ||
return await this.contactService.add(contactDto); | ||
} | ||
|
||
@ApiTags('Contacts') | ||
@Controller('contacts') | ||
export class ContactController { | ||
constructor(private readonly contactService: ContactService) { } | ||
|
||
@Post() | ||
@Public() | ||
@ApiOperation({ summary: 'Save contact information' }) | ||
async add(@Body() contactDto: CreateContactDto) { | ||
return await this.contactService.add(contactDto); | ||
} | ||
|
||
|
||
} |
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,44 @@ | ||
import { Repository } from 'typeorm'; | ||
import { Contact } from './entities/contact.entity'; | ||
import { ContactService } from './contact.service'; | ||
import { MailService } from '../mail/mail.service'; | ||
import { MailerService } from '@nestjs-modules/mailer'; | ||
|
||
describe('ContactService', () => { | ||
let service: ContactService; | ||
let contactRepository: Repository<Contact>; | ||
let mailService: MailService; | ||
let mailerService: MailerService; | ||
const mockContact: Contact = { | ||
fullname: 'test name', | ||
email: '[email protected]', | ||
object: 'no', | ||
message: 'not much to say', | ||
id: 'ca415c08-1bf1-4b67-b9d4-a2838fcd671b', | ||
updatedAt: new Date(), | ||
createdAt: new Date(), | ||
}; | ||
|
||
beforeEach(async () => { | ||
contactRepository = { | ||
create: jest.fn().mockReturnValue(mockContact), | ||
save: jest.fn().mockReturnValue(mockContact), | ||
findOne: jest.fn().mockReturnValue(mockContact), | ||
createQueryBuilder: jest.fn().mockReturnValue({}), | ||
} as unknown as Repository<Contact>; | ||
|
||
service = new ContactService(contactRepository, mailService); | ||
mailService = new MailService(mailerService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
it('mail service should be defined', () => { | ||
expect(mailService).toBeDefined(); | ||
}); | ||
// it('add a new contact', async () => { | ||
// const result = await service.add(mockContact); | ||
// expect(result).toEqual(mockContact); | ||
// }); | ||
}); |
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,34 @@ | ||
import { Repository } from 'typeorm'; | ||
import { SavingService } from './saving.service'; | ||
import { Saving, SavingFrequency, SavingType } from './entities/saving.entity'; | ||
import { User } from '../session/entities/user.entity'; | ||
import { SessionService } from '../session/session.service'; | ||
import { CreateSavingDto } from './dto/saving.dto'; | ||
|
||
describe('SavingService', () => { | ||
let service: SavingService; | ||
let userService: SessionService; | ||
let savingRepository: Repository<Saving>; | ||
let userRepository: Repository<User>; | ||
let mockSaving: CreateSavingDto = { | ||
user: 'ca415c08-1bf1-4b67-b9d4-a2838fcd671b', | ||
type: SavingType.PourMoi, | ||
amount: 200, | ||
currency: 'USD', | ||
frequency: SavingFrequency.day, | ||
operations: undefined, | ||
}; | ||
|
||
beforeEach(async () => { | ||
savingRepository = { | ||
create: jest.fn().mockReturnValue(mockSaving), | ||
save: jest.fn().mockReturnValue(mockSaving), | ||
findOne: jest.fn().mockReturnValue(mockSaving), | ||
createQueryBuilder: jest.fn().mockReturnValue({}), | ||
} as unknown as Repository<Saving>; | ||
service = new SavingService(savingRepository, userRepository); | ||
}); | ||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
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
Oops, something went wrong.