Skip to content

Commit 4c22feb

Browse files
refactor(): adjust coding style
1 parent 89e5a1d commit 4c22feb

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

packages/core/router/routes-resolver.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ export class RoutesResolver implements Resolver {
7575
const url = applicationRef.getRequestUrl(req);
7676
throw new NotFoundException(`Cannot ${method} ${url}`);
7777
};
78-
const handler = this.routerExceptionsFilter.create(
79-
{},
80-
callback,
81-
undefined,
82-
);
78+
const handler = this.routerExceptionsFilter.create({}, callback, undefined);
8379
const proxy = this.routerProxy.createProxy(callback, handler);
8480
applicationRef.setNotFoundHandler &&
8581
applicationRef.setNotFoundHandler(proxy);

packages/core/test/router/routes-resolver.spec.ts

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { BadRequestException, Post, Module } from '@nestjs/common';
1+
import { BadRequestException, Module, Post } from '@nestjs/common';
2+
import { MODULE_PATH } from '@nestjs/common/constants';
23
import { expect } from 'chai';
34
import * as sinon from 'sinon';
45
import { Controller } from '../../../common/decorators/core/controller.decorator';
56
import { Get } from '../../../common/decorators/http/request-mapping.decorator';
67
import { ExpressAdapter } from '../../adapters/express-adapter';
78
import { ApplicationConfig } from '../../application-config';
89
import { RoutesResolver } from '../../router/routes-resolver';
9-
import { MODULE_PATH } from '@nestjs/common/constants';
1010

1111
describe('RoutesResolver', () => {
12-
1312
@Controller('global')
1413
class TestRoute {
1514
@Get('test')
@@ -20,12 +19,12 @@ describe('RoutesResolver', () => {
2019
}
2120

2221
@Module({
23-
controllers: [TestRoute]
22+
controllers: [TestRoute],
2423
})
2524
class TestModule {}
2625

2726
@Module({
28-
controllers: [TestRoute]
27+
controllers: [TestRoute],
2928
})
3029
class TestModule2 {}
3130

@@ -129,9 +128,27 @@ describe('RoutesResolver', () => {
129128
routesResolver.resolve(applicationRef, 'api/v1');
130129

131130
// with module path
132-
expect(spy.getCall(0).calledWith(sinon.match.any, sinon.match.any, 'api/v1/test', sinon.match.any)).to.be.true;
131+
expect(
132+
spy
133+
.getCall(0)
134+
.calledWith(
135+
sinon.match.any,
136+
sinon.match.any,
137+
'api/v1/test',
138+
sinon.match.any,
139+
),
140+
).to.be.true;
133141
// without module path
134-
expect(spy.getCall(1).calledWith(sinon.match.any, sinon.match.any, 'api/v1', sinon.match.any)).to.be.true;
142+
expect(
143+
spy
144+
.getCall(1)
145+
.calledWith(
146+
sinon.match.any,
147+
sinon.match.any,
148+
'api/v1',
149+
sinon.match.any,
150+
),
151+
).to.be.true;
135152
});
136153

137154
it('should register each module with __module_path__ if present and no basePath ', () => {
@@ -152,11 +169,24 @@ describe('RoutesResolver', () => {
152169
routesResolver.resolve(applicationRef, '');
153170

154171
// with module path
155-
expect(spy.getCall(0).calledWith(sinon.match.any, sinon.match.any, '/test', sinon.match.any)).to.be.true;
172+
expect(
173+
spy
174+
.getCall(0)
175+
.calledWith(
176+
sinon.match.any,
177+
sinon.match.any,
178+
'/test',
179+
sinon.match.any,
180+
),
181+
).to.be.true;
156182
// without module path
157-
expect(spy.getCall(1).calledWith(sinon.match.any, sinon.match.any, '', sinon.match.any)).to.be.true;
183+
expect(
184+
spy
185+
.getCall(1)
186+
.calledWith(sinon.match.any, sinon.match.any, '', sinon.match.any),
187+
).to.be.true;
158188
});
159-
})
189+
});
160190
});
161191

162192
describe('mapExternalExceptions', () => {

0 commit comments

Comments
 (0)