Improved some tests
This commit is contained in:
parent
c33cc366d6
commit
d7728f1ca4
|
|
@ -1,24 +0,0 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { INestApplication } from '@nestjs/common';
|
|
||||||
import * as request from 'supertest';
|
|
||||||
import { AppModule } from './../src/app.module';
|
|
||||||
|
|
||||||
describe('AppController (e2e)', () => {
|
|
||||||
let app: INestApplication;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
||||||
imports: [AppModule],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
app = moduleFixture.createNestApplication();
|
|
||||||
await app.init();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('/ (GET)', () => {
|
|
||||||
return request(app.getHttpServer())
|
|
||||||
.get('/')
|
|
||||||
.expect(200)
|
|
||||||
.expect('Hello World!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"moduleFileExtensions": ["js", "json", "ts"],
|
|
||||||
"rootDir": ".",
|
|
||||||
"testEnvironment": "node",
|
|
||||||
"testRegex": ".e2e-spec.ts$",
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(t|j)s$": "ts-jest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"test:cov": "jest --coverage",
|
"test:cov": "jest --coverage",
|
||||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
"test:e2e": "jest --config e2e-tests/jest-e2e.json",
|
|
||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
@ -77,7 +76,7 @@
|
||||||
"collectCoverageFrom": [
|
"collectCoverageFrom": [
|
||||||
"**/*.(t|j)s"
|
"**/*.(t|j)s"
|
||||||
],
|
],
|
||||||
"coverageDirectory": "../coverage",
|
"coverageDirectory": "<rootDir>/coverage",
|
||||||
"testEnvironment": "node",
|
"testEnvironment": "node",
|
||||||
"moduleNameMapper": {
|
"moduleNameMapper": {
|
||||||
"@/(.*)": "<rootDir>/src/$1",
|
"@/(.*)": "<rootDir>/src/$1",
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,24 @@ describe('uuidTransformer util', () => {
|
||||||
expect(transformer.from(null)).toBe(NIL);
|
expect(transformer.from(null)).toBe(NIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('From method should throw an error if paring an invalid length buffer', () => {
|
||||||
|
expect(() => transformer.from(Buffer.alloc(15))).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
it('From method should return a nil uuid if empty 16 length buffer is passed', () => {
|
it('From method should return a nil uuid if empty 16 length buffer is passed', () => {
|
||||||
expect(transformer.from(Buffer.alloc(16))).toBe(NIL);
|
expect(transformer.from(Buffer.alloc(16))).toBe(NIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('From and To methods should be each others inverse', () => {
|
||||||
|
const uuid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';
|
||||||
|
expect(transformer.from(transformer.to(uuid))).toBe(uuid);
|
||||||
|
});
|
||||||
|
|
||||||
it('To method should return a buffer matching the uuid', () => {
|
it('To method should return a buffer matching the uuid', () => {
|
||||||
expect(transformer.to(NIL)).toEqual(Buffer.alloc(16));
|
expect(transformer.to(NIL)).toEqual(Buffer.alloc(16));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('To method throw an error if passing a string that does not match a uuid', () => {
|
||||||
|
expect(() => transformer.to('test')).toThrow();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue