Skip to content

Commit

Permalink
fix: prettier issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ki8vi committed Aug 16, 2024
1 parent fb4c737 commit 5319315
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/app/api/models/errorResponse.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { HttpErrorResponse } from "@angular/common/http";
import { HttpErrorResponse } from '@angular/common/http';

interface Error {
message: string;
reason: string;
message: string;
reason: string;
}

export interface OverriddenHttpErrorResponse extends HttpErrorResponse {
error: Error;
error: Error;
}
6 changes: 3 additions & 3 deletions src/app/api/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface User {
email: string;
password: string;
}
email: string;
password: string;
}
33 changes: 17 additions & 16 deletions src/app/api/signUpService/sign-up.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { TestBed } from '@angular/core/testing';
import { provideHttpClient } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { SignUpService } from './sign-up.service';
import { User } from '../models/user';
import { TestBed } from '@angular/core/testing';

import { OverriddenHttpErrorResponse } from '../models/errorResponse';
import { User } from '../models/user';
import { SignUpService } from './sign-up.service';

describe('SignUpService', () => {
let service: SignUpService;
let httpTestingController: HttpTestingController;

beforeEach(() => {
TestBed.configureTestingModule({
providers: [
provideHttpClient(),
provideHttpClientTesting(),
],
providers: [provideHttpClient(), provideHttpClientTesting()],
});
service = TestBed.inject(SignUpService);
httpTestingController = TestBed.inject(HttpTestingController);
Expand All @@ -32,7 +30,7 @@ describe('SignUpService', () => {
const userData: User = { email: '[email protected]', password: 'Abcdefghigk' };
service.signUp(userData).subscribe((res) => {
expect(res).toEqual({});
done()
done();
});

const req = httpTestingController.expectOne('/api/signup');
Expand All @@ -43,7 +41,7 @@ describe('SignUpService', () => {

it('should correctly handle error if user already exist', (done) => {
const userData: User = { email: '[email protected]', password: 'Passwordtest' };

service.signUp(userData).subscribe({
next: () => fail('expected error from server'),
error: (err: OverriddenHttpErrorResponse) => {
Expand All @@ -52,16 +50,19 @@ describe('SignUpService', () => {
expect(err.error.reason).toBe('invalidUniqueKey');
expect(err.ok).toBe(false);
done();
}
},
});

const req = httpTestingController.expectOne('/api/signup');
expect(req.request.method).toBe('POST');
expect(req.request.body).toEqual(userData);

req.flush({
message: 'User already exists',
reason: 'invalidUniqueKey'
}, { status: 400, statusText: 'Bad Request' });

req.flush(
{
message: 'User already exists',
reason: 'invalidUniqueKey',
},
{ status: 400, statusText: 'Bad Request' },
);
});
});
4 changes: 3 additions & 1 deletion src/app/api/signUpService/sign-up.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';

import { Observable } from 'rxjs';

import { User } from '../models/user';

@Injectable({
Expand All @@ -21,4 +23,4 @@ export class SignUpService {
console.error(err.error.message); -> errors
},
});
*/
*/
4 changes: 2 additions & 2 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { provideHttpClient } from '@angular/common/http';
import { ApplicationConfig, provideExperimentalZonelessChangeDetection } from '@angular/core';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { provideRouter, withComponentInputBinding, withInMemoryScrolling, withViewTransitions } from '@angular/router';
import { provideHttpClient } from '@angular/common/http';

import routes from './app.routes';

Expand All @@ -15,7 +15,7 @@ const appConfig: ApplicationConfig = {
withInMemoryScrolling({ scrollPositionRestoration: 'enabled' }),
),
provideAnimationsAsync(),
provideHttpClient()
provideHttpClient(),
],
};
export default appConfig;
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { bootstrapApplication } from '@angular/platform-browser';

import { startServer } from '@planess/train-a-backend';

import { AppComponent } from './app/app.component';
import appConfig from './app/app.config';

startServer()
.then(() => bootstrapApplication(AppComponent, appConfig))
.catch((err) => {
throw new Error(String(err))
.catch((err) => {
throw new Error(String(err));
});

0 comments on commit 5319315

Please sign in to comment.