-
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.
- Loading branch information
Showing
17 changed files
with
194 additions
and
54 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
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,18 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
transform: { | ||
'^.+\\.(t|j)s$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['js', 'json', 'ts'], | ||
moduleNameMapper: { | ||
'^~/(.*)$': '../src/$1', | ||
}, | ||
testEnvironment: 'node', | ||
rootDir: './src', | ||
testRegex: '.*\\.spec\\.ts$', | ||
transform: { | ||
'^.+\\.(t|j)s$': 'ts-jest', | ||
}, | ||
collectCoverageFrom: ['**/*.(t|j)s'], | ||
coverageDirectory: '../coverage', | ||
} |
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,19 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
|
||
import { DogsController } from './dogs.controller' | ||
|
||
describe('DogsController', () => { | ||
let controller: DogsController | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [DogsController], | ||
}).compile() | ||
|
||
controller = module.get<DogsController>(DogsController) | ||
}) | ||
|
||
it('should be defined', () => { | ||
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Dog } from '@company/types' | ||
import { Controller, Get } from '@nestjs/common' | ||
|
||
import { DogsService } from './dogs.service' | ||
|
||
@Controller('dogs') | ||
export class DogsController { | ||
constructor(private readonly dogsService: DogsService) {} | ||
|
||
@Get() | ||
async findAll(): Promise<Dog[]> { | ||
return this.dogsService.findAll() | ||
} | ||
} |
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 { Module } from '@nestjs/common' | ||
|
||
import { DogsController } from './dogs.controller' | ||
import { DogsService } from './dogs.service' | ||
|
||
@Module({ | ||
controllers: [DogsController], | ||
providers: [DogsService], | ||
}) | ||
export class DogsModule {} |
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,19 @@ | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
|
||
import { DogsService } from './dogs.service' | ||
|
||
describe('DogsService', () => { | ||
let service: DogsService | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [DogsService], | ||
}).compile() | ||
|
||
service = module.get<DogsService>(DogsService) | ||
}) | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Dog } from '@company/types' | ||
import { Injectable } from '@nestjs/common' | ||
|
||
@Injectable() | ||
export class DogsService { | ||
async findAll(): Promise<Dog[]> { | ||
return [ | ||
{ | ||
_id: '1', | ||
name: 'Barnaba', | ||
}, | ||
{ | ||
_id: '2', | ||
name: 'Homelander', | ||
}, | ||
{ | ||
_id: '3', | ||
name: 'Butcher', | ||
}, | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { INestApplication } from '@nestjs/common' | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import request from 'supertest' | ||
|
||
import { DogsModule } from '~/dogs/dogs.module' | ||
import { DogsService } from '~/dogs/dogs.service' | ||
|
||
describe('UsersController (e2e)', () => { | ||
let app: INestApplication | ||
|
||
const dogsServiceMock = { | ||
findAll: jest.fn().mockResolvedValue([]), | ||
} | ||
|
||
beforeEach(async () => { | ||
const moduleRef: TestingModule = await Test.createTestingModule({ | ||
imports: [DogsModule], | ||
}) | ||
.overrideProvider(DogsService) | ||
.useValue(dogsServiceMock) | ||
.compile() | ||
|
||
app = moduleRef.createNestApplication() | ||
await app.init() | ||
}) | ||
|
||
it('[GET] /users', async () => { | ||
await request(app.getHttpServer()).get('/dogs').expect(200).expect([]) | ||
}) | ||
|
||
afterAll(async () => { | ||
await app.close() | ||
}) | ||
}) |
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,32 @@ | ||
// const { pathsToModuleNameMapper } = require('ts-jest') | ||
|
||
// // In the following statement, replace `./tsconfig` with the path to your `tsconfig` file | ||
// // which contains the path mapping (ie the `compilerOptions.paths` option): | ||
// const { compilerOptions } = require('./tsconfig.json') | ||
|
||
module.exports = { | ||
preset: 'ts-jest', | ||
transform: { | ||
'^.+\\.(t|j)s$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['js', 'json', 'ts'], | ||
moduleNameMapper: { | ||
'^~/(.*)$': '../src/$1', | ||
}, | ||
testEnvironment: 'node', | ||
|
||
rootDir: '.', | ||
testRegex: '.e2e-spec.ts$', | ||
collectCoverageFrom: ['**/*.(t|j)s'], | ||
coverageDirectory: '../coverage', | ||
} | ||
|
||
// { | ||
// // "moduleFileExtensions": ["js", "json", "ts"], | ||
// "rootDir": ".", | ||
// "testEnvironment": "node", | ||
|
||
// "transform": { | ||
// "^.+\\.(t|j)s$": "ts-jest" | ||
// } | ||
// } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,8 @@ export type Cat = { | |
age: number | ||
breed: string | ||
} | ||
|
||
export type Dog = { | ||
_id: string | ||
name: string | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.