forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@nestjs) reactive microservices, custom transport strategy, webs…
…ockets adapter, exception filters breaking change, async pipes feature
- Loading branch information
kamil.mysliwiec
committed
May 31, 2017
1 parent
07d7768
commit 9bf3661
Showing
35 changed files
with
527 additions
and
125 deletions.
There are no files selected for viewing
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 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
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,26 @@ | ||
import 'reflect-metadata'; | ||
import { expect } from 'chai'; | ||
import { UsePipes } from '../../utils/decorators/use-pipes.decorator'; | ||
import { PIPES_METADATA } from './../../constants'; | ||
|
||
describe('@UsePipes', () => { | ||
const pipes = [ 'pipe1', 'pipe2' ]; | ||
|
||
@UsePipes(...pipes as any) class Test {} | ||
|
||
class TestWithMethod { | ||
@UsePipes(...pipes as any) | ||
public static test() {} | ||
} | ||
|
||
it('should enhance class with expected pipes array', () => { | ||
const metadata = Reflect.getMetadata(PIPES_METADATA, Test); | ||
expect(metadata).to.be.eql(pipes); | ||
}); | ||
|
||
it('should enhance method with expected pipes array', () => { | ||
const metadata = Reflect.getMetadata(PIPES_METADATA, TestWithMethod.test); | ||
expect(metadata).to.be.eql(pipes); | ||
}); | ||
|
||
}); |
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
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
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,34 @@ | ||
import { expect } from 'chai'; | ||
import { ParamsTokenFactory } from './../../pipes/params-token-factory'; | ||
import { RouteParamtypes } from '../../../common/enums/route-paramtypes.enum'; | ||
|
||
describe('ParamsTokenFactory', () => { | ||
let factory: ParamsTokenFactory; | ||
beforeEach(() => { | ||
factory = new ParamsTokenFactory(); | ||
}); | ||
describe('exchangeEnumForString', () => { | ||
describe('when key is', () => { | ||
describe(`RouteParamtypes.BODY`, () => { | ||
it('should returns body object', () => { | ||
expect(factory.exchangeEnumForString(RouteParamtypes.BODY)).to.be.eql('body'); | ||
}); | ||
}); | ||
describe(`RouteParamtypes.QUERY`, () => { | ||
it('should returns query object', () => { | ||
expect(factory.exchangeEnumForString(RouteParamtypes.QUERY)).to.be.eql('query'); | ||
}); | ||
}); | ||
describe(`RouteParamtypes.PARAM`, () => { | ||
it('should returns params object', () => { | ||
expect(factory.exchangeEnumForString(RouteParamtypes.PARAM)).to.be.eql('param'); | ||
}); | ||
}); | ||
describe('not available', () => { | ||
it('should returns null', () => { | ||
expect(factory.exchangeEnumForString(-1)).to.be.eql(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,38 @@ | ||
import * as sinon from 'sinon'; | ||
import { expect } from 'chai'; | ||
import { PipesConsumer } from './../../pipes/pipes-consumer'; | ||
import { RouteParamtypes } from './../../../common/enums/route-paramtypes.enum'; | ||
|
||
describe('PipesConsumer', () => { | ||
let consumer: PipesConsumer; | ||
beforeEach(() => { | ||
consumer = new PipesConsumer(); | ||
}); | ||
describe('apply', () => { | ||
let value, metatype, type, stringifiedType, transforms; | ||
beforeEach(() => { | ||
value = 0; | ||
metatype = {}, | ||
type = RouteParamtypes.QUERY; | ||
stringifiedType = 'query'; | ||
transforms = [ | ||
sinon.stub().callsFake((val) => val + 1), | ||
sinon.stub().callsFake((val) => Promise.resolve(val + 1)), | ||
sinon.stub().callsFake((val) => val + 1), | ||
]; | ||
}); | ||
it('should call all transform functions', (done) => { | ||
consumer.apply(value, metatype, type, transforms).then(() => { | ||
expect(transforms.reduce((prev, next) => prev && next.called, true)).to.be.true; | ||
done(); | ||
}); | ||
}); | ||
it('should returns expected result', (done) => { | ||
const expectedResult = 3; | ||
consumer.apply(value, metatype, type, transforms).then((result) => { | ||
expect(result).to.be.eql(expectedResult); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.