refactor(): update to the latest version of prettier

This commit is contained in:
Kamil Myśliwiec
2020-03-22 12:10:49 +01:00
parent 3dae6178b7
commit 0e5b402a6f
32 changed files with 70 additions and 150 deletions

View File

@@ -1,4 +1,5 @@
{ {
"singleQuote": true, "singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "all" "trailingComma": "all"
} }

View File

@@ -18,10 +18,7 @@ describe('Error messages', () => {
}); });
it(`/GET`, () => { it(`/GET`, () => {
return request(server) return request(server).get('/sync').expect(HttpStatus.BAD_REQUEST).expect({
.get('/sync')
.expect(HttpStatus.BAD_REQUEST)
.expect({
statusCode: 400, statusCode: 400,
error: 'Bad Request', error: 'Bad Request',
message: 'Integration test', message: 'Integration test',
@@ -29,10 +26,7 @@ describe('Error messages', () => {
}); });
it(`/GET (Promise/async)`, () => { it(`/GET (Promise/async)`, () => {
return request(server) return request(server).get('/async').expect(HttpStatus.BAD_REQUEST).expect({
.get('/async')
.expect(HttpStatus.BAD_REQUEST)
.expect({
statusCode: 400, statusCode: 400,
error: 'Bad Request', error: 'Bad Request',
message: 'Integration test', message: 'Integration test',

View File

@@ -78,16 +78,11 @@ describe('Exclude middleware (fastify)', () => {
).createNestApplication<NestFastifyApplication>(new FastifyAdapter()); ).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
await app.init(); await app.init();
await app await app.getHttpAdapter().getInstance().ready();
.getHttpAdapter()
.getInstance()
.ready();
}); });
it(`should exclude "/test" endpoint`, () => { it(`should exclude "/test" endpoint`, () => {
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
.get('/test')
.expect(200, RETURN_VALUE);
}); });
it(`should not exclude "/test2" endpoint`, () => { it(`should not exclude "/test2" endpoint`, () => {

View File

@@ -77,9 +77,7 @@ describe('Exclude middleware', () => {
}); });
it(`should exclude "/test" endpoint`, () => { it(`should exclude "/test" endpoint`, () => {
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/test').expect(200, RETURN_VALUE);
.get('/test')
.expect(200, RETURN_VALUE);
}); });
it(`should not exclude "/test2" endpoint`, () => { it(`should not exclude "/test2" endpoint`, () => {

View File

@@ -20,10 +20,7 @@ describe('Hello world (express instance)', () => {
}); });
it(`/GET`, () => { it(`/GET`, () => {
return request(server) return request(server).get('/hello').expect(200).expect('Hello world!');
.get('/hello')
.expect(200)
.expect('Hello world!');
}); });
it(`/GET (Promise/async)`, () => { it(`/GET (Promise/async)`, () => {
@@ -41,10 +38,7 @@ describe('Hello world (express instance)', () => {
}); });
it(`/GET { host: ":tenant.example.com" } not matched`, () => { it(`/GET { host: ":tenant.example.com" } not matched`, () => {
return request(server) return request(server).get('/host').expect(404).expect({
.get('/host')
.expect(404)
.expect({
statusCode: 404, statusCode: 404,
error: 'Not Found', error: 'Not Found',
message: 'Cannot GET /host', message: 'Cannot GET /host',

View File

@@ -29,10 +29,7 @@ describe('Hello world (express instance with multiple applications)', () => {
}); });
it(`/GET`, () => { it(`/GET`, () => {
return request(server) return request(server).get('/hello').expect(200).expect('Hello world!');
.get('/hello')
.expect(200)
.expect('Hello world!');
}); });
it(`/GET (app2)`, () => { it(`/GET (app2)`, () => {

View File

@@ -37,8 +37,6 @@ describe('Guards', () => {
app = (await createTestModule(new AuthGuard())).createNestApplication(); app = (await createTestModule(new AuthGuard())).createNestApplication();
await app.init(); await app.init();
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/hello').expect(401);
.get('/hello')
.expect(401);
}); });
}); });

View File

@@ -77,9 +77,7 @@ describe('Interceptors', () => {
).createNestApplication(); ).createNestApplication();
await app.init(); await app.init();
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
.get('/hello')
.expect(200, RETURN_VALUE);
}); });
it(`should map response`, async () => { it(`should map response`, async () => {

View File

@@ -18,10 +18,7 @@ describe('Hello world (default adapter)', () => {
}); });
it(`host=example.com should execute locally injected pipe by HelloController`, () => { it(`host=example.com should execute locally injected pipe by HelloController`, () => {
return request(server) return request(server).get('/hello/local-pipe/1').expect(200).expect({
.get('/hello/local-pipe/1')
.expect(200)
.expect({
id: '1', id: '1',
}); });
}); });
@@ -39,10 +36,7 @@ describe('Hello world (default adapter)', () => {
}); });
it(`should return 404 for mismatched host`, () => { it(`should return 404 for mismatched host`, () => {
return request(server) return request(server).get('/host/local-pipe/1').expect(404).expect({
.get('/host/local-pipe/1')
.expect(404)
.expect({
error: 'Not Found', error: 'Not Found',
message: 'Cannot GET /host/local-pipe/1', message: 'Cannot GET /host/local-pipe/1',
statusCode: 404, statusCode: 404,

View File

@@ -51,9 +51,7 @@ describe('Middleware (class)', () => {
}); });
it(`forRoutes(*)`, () => { it(`forRoutes(*)`, () => {
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
.get('/hello')
.expect(200, RETURN_VALUE);
}); });
afterEach(async () => { afterEach(async () => {

View File

@@ -57,15 +57,11 @@ describe('Middleware', () => {
}); });
it(`forRoutes(*)`, () => { it(`forRoutes(*)`, () => {
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/hello').expect(200, RETURN_VALUE);
.get('/hello')
.expect(200, RETURN_VALUE);
}); });
it(`forRoutes(TestController)`, () => { it(`forRoutes(TestController)`, () => {
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/test').expect(200, SCOPED_VALUE);
.get('/test')
.expect(200, SCOPED_VALUE);
}); });
it(`forRoutes(tests/*)`, () => { it(`forRoutes(tests/*)`, () => {

View File

@@ -33,9 +33,7 @@ describe('MQTT transport', () => {
}); });
it(`Broadcast (2 subscribers)`, () => { it(`Broadcast (2 subscribers)`, () => {
return request(server) return request(server).get('/broadcast').expect(200, '2');
.get('/broadcast')
.expect(200, '2');
}); });
afterEach(async () => { afterEach(async () => {

View File

@@ -33,9 +33,7 @@ describe('NATS transport', () => {
}); });
it(`Broadcast (2 subscribers)`, () => { it(`Broadcast (2 subscribers)`, () => {
return request(server) return request(server).get('/broadcast').expect(200, '2');
.get('/broadcast')
.expect(200, '2');
}); });
afterEach(async () => { afterEach(async () => {

View File

@@ -33,9 +33,7 @@ describe('REDIS transport', () => {
}); });
it(`Broadcast (2 subscribers)`, () => { it(`Broadcast (2 subscribers)`, () => {
return request(server) return request(server).get('/broadcast').expect(200, '2');
.get('/broadcast')
.expect(200, '2');
}); });
afterEach(async () => { afterEach(async () => {

View File

@@ -129,11 +129,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => { callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error // We want to fail only on real errors while Cancellation error
// is expected // is expected
if ( if (String(err).toLowerCase().indexOf('cancelled') === -1) {
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
fail('gRPC Stream error happened, error: ' + err); fail('gRPC Stream error happened, error: ' + err);
} }
}); });
@@ -165,11 +161,7 @@ describe('Advanced GRPC transport', () => {
callHandler.on('error', (err: any) => { callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error // We want to fail only on real errors while Cancellation error
// is expected // is expected
if ( if (String(err).toLowerCase().indexOf('cancelled') === -1) {
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
fail('gRPC Stream error happened, error: ' + err); fail('gRPC Stream error happened, error: ' + err);
} }
}); });

View File

@@ -63,11 +63,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => { callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error // We want to fail only on real errors while Cancellation error
// is expected // is expected
if ( if (String(err).toLowerCase().indexOf('cancelled') === -1) {
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
fail('gRPC Stream error happened, error: ' + err); fail('gRPC Stream error happened, error: ' + err);
} }
}); });
@@ -89,11 +85,7 @@ describe('GRPC transport', () => {
callHandler.on('error', (err: any) => { callHandler.on('error', (err: any) => {
// We want to fail only on real errors while Cancellation error // We want to fail only on real errors while Cancellation error
// is expected // is expected
if ( if (String(err).toLowerCase().indexOf('cancelled') === -1) {
String(err)
.toLowerCase()
.indexOf('cancelled') === -1
) {
fail('gRPC Stream error happened, error: ' + err); fail('gRPC Stream error happened, error: ' + err);
} }
}); });

View File

@@ -106,17 +106,11 @@ describe('Kafka transport', () => {
user: newUser, user: newUser,
}; };
it(`/POST (sync command create user)`, () => { it(`/POST (sync command create user)`, () => {
return request(server) return request(server).post('/user').send(userDto).expect(200);
.post('/user')
.send(userDto)
.expect(200);
}); });
it(`/POST (sync command create business`, () => { it(`/POST (sync command create business`, () => {
return request(server) return request(server).post('/business').send(businessDto).expect(200);
.post('/business')
.send(businessDto)
.expect(200);
}); });
it(`/POST (sync command create user) Concurrency Test`, async () => { it(`/POST (sync command create user) Concurrency Test`, async () => {
@@ -124,12 +118,7 @@ describe('Kafka transport', () => {
for (let concurrencyKey = 0; concurrencyKey < 100; concurrencyKey++) { for (let concurrencyKey = 0; concurrencyKey < 100; concurrencyKey++) {
const innerUserDto = JSON.parse(JSON.stringify(userDto)); const innerUserDto = JSON.parse(JSON.stringify(userDto));
innerUserDto.name += `+${concurrencyKey}`; innerUserDto.name += `+${concurrencyKey}`;
promises.push( promises.push(request(server).post('/user').send(userDto).expect(200));
request(server)
.post('/user')
.send(userDto)
.expect(200),
);
} }
await Promise.all(promises); await Promise.all(promises);
}); });

View File

@@ -75,9 +75,7 @@ describe('NATS transport', () => {
}); });
it(`/GET (exception)`, () => { it(`/GET (exception)`, () => {
return request(server) return request(server).get('/exception').expect(200, {
.get('/exception')
.expect(200, {
message: 'test', message: 'test',
status: 'error', status: 'error',
}); });

View File

@@ -76,9 +76,7 @@ describe('RPC transport', () => {
}); });
it(`/POST (pattern not found)`, () => { it(`/POST (pattern not found)`, () => {
return request(server) return request(server).post('/?command=test').expect(500);
.post('/?command=test')
.expect(500);
}); });
it(`/POST (event notification)`, done => { it(`/POST (event notification)`, done => {

View File

@@ -3,8 +3,9 @@ import { RuntimeException } from './runtime.exception';
export class UnknownElementException extends RuntimeException { export class UnknownElementException extends RuntimeException {
constructor(name?: string) { constructor(name?: string) {
super( super(
`Nest could not find ${name || `Nest could not find ${
'given'} element (this provider does not exist in the current context)`, name || 'given'
} element (this provider does not exist in the current context)`,
); );
} }
} }

View File

@@ -109,8 +109,9 @@ export const INVALID_CLASS_SCOPE_MESSAGE = (
text: TemplateStringsArray, text: TemplateStringsArray,
name: string | undefined, 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 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.`; export const UNKNOWN_REQUEST_MAPPING = `An invalid controller has been detected. Perhaps, one of your controllers is missing @Controller() decorator.`;

View File

@@ -138,12 +138,7 @@ export class NestApplicationContext implements INestApplicationContext {
} }
signals = signals signals = signals
.map((signal: string) => .map((signal: string) => signal.toString().toUpperCase().trim())
signal
.toString()
.toUpperCase()
.trim(),
)
// filter out the signals which is already listening to // filter out the signals which is already listening to
.filter(signal => !this.activeShutdownSignals.includes(signal)); .filter(signal => !this.activeShutdownSignals.includes(signal));

View File

@@ -313,7 +313,9 @@ export class DependenciesScanner {
if (!providersKeys.includes(type as string)) { if (!providersKeys.includes(type as string)) {
return this.container.addProvider(provider as any, token); return this.container.addProvider(provider as any, token);
} }
const providerToken = `${type as string} (UUID: ${randomStringGenerator()})`; const providerToken = `${
type as string
} (UUID: ${randomStringGenerator()})`;
let scope = (provider as ClassProvider | FactoryProvider).scope; let scope = (provider as ClassProvider | FactoryProvider).scope;
if (isNil(scope) && (provider as ClassProvider).useClass) { if (isNil(scope) && (provider as ClassProvider).useClass) {

View File

@@ -240,9 +240,7 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
call.on('data', (m: any) => req.next(m)); call.on('data', (m: any) => req.next(m));
call.on('error', (e: any) => { call.on('error', (e: any) => {
// Check if error means that stream ended on other end // Check if error means that stream ended on other end
const isCancelledError = String(e) const isCancelledError = String(e).toLowerCase().indexOf('cancelled');
.toLowerCase()
.indexOf('cancelled');
if (isCancelledError) { if (isCancelledError) {
call.end(); call.end();

View File

@@ -23,10 +23,7 @@ describe('Cats', () => {
}); });
it(`/GET cats`, () => { it(`/GET cats`, () => {
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/cats').expect(200).expect({
.get('/cats')
.expect(200)
.expect({
data: catsService.findAll(), data: catsService.findAll(),
}); });
}); });