Skip to content

Commit

Permalink
refactor(): update to the latest version of prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Mar 22, 2020
1 parent 3dae617 commit 0e5b402
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 150 deletions.
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "all"
}
26 changes: 10 additions & 16 deletions integration/hello-world/e2e/exceptions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,19 @@ describe('Error messages', () => {
});

it(`/GET`, () => {
return request(server)
.get('/sync')
.expect(HttpStatus.BAD_REQUEST)
.expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
return request(server).get('/sync').expect(HttpStatus.BAD_REQUEST).expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
});

it(`/GET (Promise/async)`, () => {
return request(server)
.get('/async')
.expect(HttpStatus.BAD_REQUEST)
.expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
return request(server).get('/async').expect(HttpStatus.BAD_REQUEST).expect({
statusCode: 400,
error: 'Bad Request',
message: 'Integration test',
});
});

afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,11 @@ describe('Exclude middleware (fastify)', () => {
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());

await app.init();
await app
.getHttpAdapter()
.getInstance()
.ready();
await app.getHttpAdapter().getInstance().ready();
});

it(`should exclude "/test" endpoint`, () => {
return request(app.getHttpServer())
.get('/test')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
});

it(`should not exclude "/test2" endpoint`, () => {
Expand Down
4 changes: 1 addition & 3 deletions integration/hello-world/e2e/exclude-middleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ describe('Exclude middleware', () => {
});

it(`should exclude "/test" endpoint`, () => {
return request(app.getHttpServer())
.get('/test')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
});

it(`should not exclude "/test2" endpoint`, () => {
Expand Down
18 changes: 6 additions & 12 deletions integration/hello-world/e2e/express-instance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ describe('Hello world (express instance)', () => {
});

it(`/GET`, () => {
return request(server)
.get('/hello')
.expect(200)
.expect('Hello world!');
return request(server).get('/hello').expect(200).expect('Hello world!');
});

it(`/GET (Promise/async)`, () => {
Expand All @@ -41,14 +38,11 @@ describe('Hello world (express instance)', () => {
});

it(`/GET { host: ":tenant.example.com" } not matched`, () => {
return request(server)
.get('/host')
.expect(404)
.expect({
statusCode: 404,
error: 'Not Found',
message: 'Cannot GET /host',
});
return request(server).get('/host').expect(404).expect({
statusCode: 404,
error: 'Not Found',
message: 'Cannot GET /host',
});
});

afterEach(async () => {
Expand Down
5 changes: 1 addition & 4 deletions integration/hello-world/e2e/express-multiple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ describe('Hello world (express instance with multiple applications)', () => {
});

it(`/GET`, () => {
return request(server)
.get('/hello')
.expect(200)
.expect('Hello world!');
return request(server).get('/hello').expect(200).expect('Hello world!');
});

it(`/GET (app2)`, () => {
Expand Down
4 changes: 1 addition & 3 deletions integration/hello-world/e2e/guards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ describe('Guards', () => {
app = (await createTestModule(new AuthGuard())).createNestApplication();

await app.init();
return request(app.getHttpServer())
.get('/hello')
.expect(401);
return request(app.getHttpServer()).get('/hello').expect(401);
});
});
4 changes: 1 addition & 3 deletions integration/hello-world/e2e/interceptors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ describe('Interceptors', () => {
).createNestApplication();

await app.init();
return request(app.getHttpServer())
.get('/hello')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
});

it(`should map response`, async () => {
Expand Down
22 changes: 8 additions & 14 deletions integration/hello-world/e2e/local-pipes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ describe('Hello world (default adapter)', () => {
});

it(`host=example.com should execute locally injected pipe by HelloController`, () => {
return request(server)
.get('/hello/local-pipe/1')
.expect(200)
.expect({
id: '1',
});
return request(server).get('/hello/local-pipe/1').expect(200).expect({
id: '1',
});
});

it(`host=host.example.com should execute locally injected pipe by HostController`, () => {
Expand All @@ -39,14 +36,11 @@ describe('Hello world (default adapter)', () => {
});

it(`should return 404 for mismatched host`, () => {
return request(server)
.get('/host/local-pipe/1')
.expect(404)
.expect({
error: 'Not Found',
message: 'Cannot GET /host/local-pipe/1',
statusCode: 404,
});
return request(server).get('/host/local-pipe/1').expect(404).expect({
error: 'Not Found',
message: 'Cannot GET /host/local-pipe/1',
statusCode: 404,
});
});

afterEach(async () => {
Expand Down
4 changes: 1 addition & 3 deletions integration/hello-world/e2e/middleware-class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ describe('Middleware (class)', () => {
});

it(`forRoutes(*)`, () => {
return request(app.getHttpServer())
.get('/hello')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
});

afterEach(async () => {
Expand Down
8 changes: 2 additions & 6 deletions integration/hello-world/e2e/middleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@ describe('Middleware', () => {
});

it(`forRoutes(*)`, () => {
return request(app.getHttpServer())
.get('/hello')
.expect(200, RETURN_VALUE);
return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
});

it(`forRoutes(TestController)`, () => {
return request(app.getHttpServer())
.get('/test')
.expect(200, SCOPED_VALUE);
return request(app.getHttpServer()).get('/test').expect(200, SCOPED_VALUE);
});

it(`forRoutes(tests/*)`, () => {
Expand Down
4 changes: 1 addition & 3 deletions integration/microservices/e2e/broadcast-mqtt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ describe('MQTT transport', () => {
});

it(`Broadcast (2 subscribers)`, () => {
return request(server)
.get('/broadcast')
.expect(200, '2');
return request(server).get('/broadcast').expect(200, '2');
});

afterEach(async () => {
Expand Down
4 changes: 1 addition & 3 deletions integration/microservices/e2e/broadcast-nats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ describe('NATS transport', () => {
});

it(`Broadcast (2 subscribers)`, () => {
return request(server)
.get('/broadcast')
.expect(200, '2');
return request(server).get('/broadcast').expect(200, '2');
});

afterEach(async () => {
Expand Down
4 changes: 1 addition & 3 deletions integration/microservices/e2e/broadcast-redis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ describe('REDIS transport', () => {
});

it(`Broadcast (2 subscribers)`, () => {
return request(server)
.get('/broadcast')
.expect(200, '2');
return request(server).get('/broadcast').expect(200, '2');
});

afterEach(async () => {
Expand Down
12 changes: 2 additions & 10 deletions integration/microservices/e2e/orders-grpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand Down Expand Up @@ -165,11 +161,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand Down
12 changes: 2 additions & 10 deletions integration/microservices/e2e/sum-grpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand All @@ -89,11 +85,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error
// is expected
if (
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
if (String(err).toLowerCase().indexOf('cancelled') === -1) {
fail('gRPC Stream error happened, error: ' + err);
}
});
Expand Down
17 changes: 3 additions & 14 deletions integration/microservices/e2e/sum-kafka.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,19 @@ describe('Kafka transport', () => {
user: newUser,
};
it(`/POST (sync command create user)`, () => {
return request(server)
.post('/user')
.send(userDto)
.expect(200);
return request(server).post('/user').send(userDto).expect(200);
});

it(`/POST (sync command create business`, () => {
return request(server)
.post('/business')
.send(businessDto)
.expect(200);
return request(server).post('/business').send(businessDto).expect(200);
});

it(`/POST (sync command create user) Concurrency Test`, async () => {
const promises = [];
for (let concurrencyKey = 0; concurrencyKey < 100; concurrencyKey++) {
const innerUserDto = JSON.parse(JSON.stringify(userDto));
innerUserDto.name += `+${concurrencyKey}`;
promises.push(
request(server)
.post('/user')
.send(userDto)
.expect(200),
);
promises.push(request(server).post('/user').send(userDto).expect(200));
}
await Promise.all(promises);
});
Expand Down
2 changes: 1 addition & 1 deletion integration/microservices/e2e/sum-mqtt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('MQTT transport', () => {
.expect(200, '15');
});

it(`/POST (concurrent)`, function() {
it(`/POST (concurrent)`, function () {
return request(server)
.post('/concurrent')
.send([
Expand Down
10 changes: 4 additions & 6 deletions integration/microservices/e2e/sum-nats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ describe('NATS transport', () => {
});

it(`/GET (exception)`, () => {
return request(server)
.get('/exception')
.expect(200, {
message: 'test',
status: 'error',
});
return request(server).get('/exception').expect(200, {
message: 'test',
status: 'error',
});
});

it(`/POST (event notification)`, done => {
Expand Down
2 changes: 1 addition & 1 deletion integration/microservices/e2e/sum-redis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('REDIS transport', () => {
.expect(200, '15');
});

it(`/POST (concurrent)`, function() {
it(`/POST (concurrent)`, function () {
this.retries(10);

return request(server)
Expand Down
4 changes: 1 addition & 3 deletions integration/microservices/e2e/sum-rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ describe('RPC transport', () => {
});

it(`/POST (pattern not found)`, () => {
return request(server)
.post('/?command=test')
.expect(500);
return request(server).post('/?command=test').expect(500);
});

it(`/POST (event notification)`, done => {
Expand Down
2 changes: 1 addition & 1 deletion integration/websockets/e2e/ws-gateway.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
);
});

it(`should support 2 different gateways`, async function() {
it(`should support 2 different gateways`, async function () {
this.retries(10);

app = await createNestApp(ApplicationGateway, CoreGateway);
Expand Down
5 changes: 3 additions & 2 deletions packages/core/errors/exceptions/unknown-element.exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { RuntimeException } from './runtime.exception';
export class UnknownElementException extends RuntimeException {
constructor(name?: string) {
super(
`Nest could not find ${name ||
'given'} element (this provider does not exist in the current context)`,
`Nest could not find ${
name || 'given'
} element (this provider does not exist in the current context)`,
);
}
}
5 changes: 3 additions & 2 deletions packages/core/errors/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ export const INVALID_CLASS_SCOPE_MESSAGE = (
text: TemplateStringsArray,
name: string | undefined,
) =>
`${name ||
'This class'} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;
`${
name || 'This class'
} is marked as a scoped provider. Request and transient-scoped providers can't be used in combination with "get()" method. Please, use "resolve()" instead.`;

export const INVALID_MIDDLEWARE_CONFIGURATION = `An invalid middleware configuration has been passed inside the module 'configure()' method.`;
export const UNKNOWN_REQUEST_MAPPING = `An invalid controller has been detected. Perhaps, one of your controllers is missing @Controller() decorator.`;
Expand Down
Loading

0 comments on commit 0e5b402

Please sign in to comment.