From 0aaca8e5de1d8969a4e60485a0105cdf7cc5cbad Mon Sep 17 00:00:00 2001 From: "stepan.moc" Date: Tue, 7 May 2024 22:49:03 +0200 Subject: [PATCH] changed css and html (#64) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * changed html and css, also refactoring and reformatting for ts and spec.ts Co-authored-by: Štěpán Moc --- .../app/auth/sign-in/sign-in.component.html | 6 +- .../src/app/auth/sign-in/sign-in.component.ts | 6 +- .../app/auth/sign-up/sign-up.component.html | 6 +- .../src/app/auth/sign-up/sign-up.component.ts | 5 +- .../src/app/auth/style/auth.component.css | 36 +---- .../app/shared/http/service/http.service.ts | 4 +- .../app/weather/service/weather.service.ts | 3 +- .../weather-detail.component.css | 48 ------- .../weather-detail.component.html | 63 ++++----- .../weather-detail.component.ts | 44 +++++-- .../weather-list/weather-list.component.html | 124 +++++++++--------- .../weather-list/weather-list.component.ts | 18 ++- .../environments/environment.development.ts | 3 +- frontend/src/environments/environment.ts | 3 +- frontend/src/styles.css | 45 ++++--- .../enviroments.development.spec.ts | 4 - .../weather/weather-detail.component.spec.ts | 60 +++++++++ .../weather/weather-list.component.spec.ts | 53 ++++---- 18 files changed, 281 insertions(+), 250 deletions(-) diff --git a/frontend/src/app/auth/sign-in/sign-in.component.html b/frontend/src/app/auth/sign-in/sign-in.component.html index 840082c..f4df103 100644 --- a/frontend/src/app/auth/sign-in/sign-in.component.html +++ b/frontend/src/app/auth/sign-in/sign-in.component.html @@ -1,10 +1,10 @@
-
-
- Sign in +
+
+ Sign in alternate_email diff --git a/frontend/src/app/auth/sign-in/sign-in.component.ts b/frontend/src/app/auth/sign-in/sign-in.component.ts index cd9af9f..f0b8bf8 100644 --- a/frontend/src/app/auth/sign-in/sign-in.component.ts +++ b/frontend/src/app/auth/sign-in/sign-in.component.ts @@ -3,7 +3,7 @@ import {AuthService} from "../service/auth.service"; import {FormBuilder, FormGroup, NG_VALUE_ACCESSOR, ReactiveFormsModule, Validators} from "@angular/forms"; import {SignInForm} from "../model/SignInForm"; import {MatFormField, MatPrefix} from "@angular/material/form-field"; -import {MatCard} from "@angular/material/card"; +import {MatCard, MatCardHeader, MatCardTitle} from "@angular/material/card"; import {MatToolbar} from "@angular/material/toolbar"; import {MatIcon} from "@angular/material/icon"; import {MatInput} from "@angular/material/input"; @@ -26,7 +26,9 @@ import {Subscription} from "rxjs"; MatButton, NgIf, ReactiveFormsModule, - MatPrefix + MatPrefix, + MatCardHeader, + MatCardTitle ], templateUrl: './sign-in.component.html', styleUrl: '../style/auth.component.css', diff --git a/frontend/src/app/auth/sign-up/sign-up.component.html b/frontend/src/app/auth/sign-up/sign-up.component.html index 8ab7123..e44502f 100644 --- a/frontend/src/app/auth/sign-up/sign-up.component.html +++ b/frontend/src/app/auth/sign-up/sign-up.component.html @@ -1,10 +1,10 @@ -
-
- Sign in +
+
+ Sign up person_outline diff --git a/frontend/src/app/auth/sign-up/sign-up.component.ts b/frontend/src/app/auth/sign-up/sign-up.component.ts index 816b1e0..9ce414a 100644 --- a/frontend/src/app/auth/sign-up/sign-up.component.ts +++ b/frontend/src/app/auth/sign-up/sign-up.component.ts @@ -2,7 +2,7 @@ import {ChangeDetectionStrategy, Component, OnDestroy, OnInit} from '@angular/co import {AuthService} from "../service/auth.service"; import {FormBuilder, FormGroup, NG_VALUE_ACCESSOR, ReactiveFormsModule, Validators} from "@angular/forms"; import {MatButton} from "@angular/material/button"; -import {MatCard} from "@angular/material/card"; +import {MatCard, MatCardTitle} from "@angular/material/card"; import {MatFormField, MatPrefix} from "@angular/material/form-field"; import {MatIcon} from "@angular/material/icon"; import {MatInput} from "@angular/material/input"; @@ -26,7 +26,8 @@ import {Subscription} from "rxjs"; MatToolbar, NgIf, ReactiveFormsModule, - MatPrefix + MatPrefix, + MatCardTitle ], templateUrl: './sign-up.component.html', styleUrl: '../style/auth.component.css', diff --git a/frontend/src/app/auth/style/auth.component.css b/frontend/src/app/auth/style/auth.component.css index 1a6c3b6..ca3d451 100644 --- a/frontend/src/app/auth/style/auth.component.css +++ b/frontend/src/app/auth/style/auth.component.css @@ -1,36 +1,6 @@ -.auth-container { - margin-top: 50px; - height: 100%; - width: 100%; - align-items: center; +mat-card-title { + background: #3f51b5; display: flex; -} - -form { - width: 100%; -} - -.auth-content { - width: 400px; - display: block; - margin: 0 auto; - border-radius: 1em; -} - -.auth-toolbar { justify-content: center; -} - -.mat-form-field { - width: 100%; -} - -.mat-raised-button { - width: 100%; - height: 60px; - margin-top: 15px; -} - -.mat-mdc-card { - background: #2c3338; + color: white; } diff --git a/frontend/src/app/shared/http/service/http.service.ts b/frontend/src/app/shared/http/service/http.service.ts index b81d68a..03539d2 100644 --- a/frontend/src/app/shared/http/service/http.service.ts +++ b/frontend/src/app/shared/http/service/http.service.ts @@ -22,7 +22,7 @@ export class HttpService { return this.httpClient.put(url, data, options) } - delete(url: string) { - return this.httpClient.delete(url, {}) + delete(url: string) { + return this.httpClient.delete(url, {}) } } diff --git a/frontend/src/app/weather/service/weather.service.ts b/frontend/src/app/weather/service/weather.service.ts index fbb0d2c..d460c79 100644 --- a/frontend/src/app/weather/service/weather.service.ts +++ b/frontend/src/app/weather/service/weather.service.ts @@ -31,8 +31,7 @@ export class WeatherService { return this.httpService.get(this.rootUrl + 'locations') } - // TODO: Fix the return type - deleteUserWeatherLocation(id: number): Observable { + deleteUserWeatherLocation(id: number): Observable { return this.httpService.delete(this.rootUrl + 'location/' + id) } } diff --git a/frontend/src/app/weather/weather-detail/weather-detail.component.css b/frontend/src/app/weather/weather-detail/weather-detail.component.css index 8658a11..8b13789 100644 --- a/frontend/src/app/weather/weather-detail/weather-detail.component.css +++ b/frontend/src/app/weather/weather-detail/weather-detail.component.css @@ -1,49 +1 @@ -.container { - width: 100%; - align-items: center; - display: flex; -} -form { - width: 100%; -} - -.content { - width: 400px; - display: block; - margin: 1em auto; - border-radius: 1em; - flex-direction: row; -} - -.mat-form-field { - width: 100%; -} - -.mat-raised-button { - width: 100%; - height: 60px; - margin-top: 15px; -} - -.mat-mdc-card { - background: white; - border-radius: 1em; - padding: 1em; -} - -.data-content { - display: flex; - margin: 1em auto; -} - -.row { - display: flex; - flex-direction: row; - justify-content: space-between; -} - -.mat-card-title { - font-size: 1.5em; - font-weight: bold; -} diff --git a/frontend/src/app/weather/weather-detail/weather-detail.component.html b/frontend/src/app/weather/weather-detail/weather-detail.component.html index 7482032..65bed73 100644 --- a/frontend/src/app/weather/weather-detail/weather-detail.component.html +++ b/frontend/src/app/weather/weather-detail/weather-detail.component.html @@ -7,43 +7,44 @@ -
-
-
-
- - Current weather - - brightness_5 - brightness_1 - - -
-

Date: {{ moment(currentWeather().time).format("DD-MM-YYYY") }}

-

Time: {{ moment(currentWeather().time).format("HH:MM") }}

-

Temperature: {{ currentWeather().temperature }} °C

-

Cloud cover: {{ currentWeather().cloudCover }} %

-

Wind speed: {{ currentWeather().temperature }} km/h

-
-
-
- - Graph of forecast weather - - brightness_5 - brightness_1 - - - - - -
+
+
+ + Current weather + + brightness_5 + brightness_1 + + +
+

Date: {{ moment(currentWeather().time).format("HH:MM DD-MM-YYYY") }}

+

Temperature: {{ currentWeather().temperature }} °C

+

Cloud cover: {{ currentWeather().cloudCover }} %

+

Wind speed: {{ currentWeather().temperature }} km/h

+
+
+
+
+
+ + Graph of forecast weather + + brightness_5 + brightness_1 + + + + +
diff --git a/frontend/src/app/weather/weather-detail/weather-detail.component.ts b/frontend/src/app/weather/weather-detail/weather-detail.component.ts index 11b10c6..ad54b6a 100644 --- a/frontend/src/app/weather/weather-detail/weather-detail.component.ts +++ b/frontend/src/app/weather/weather-detail/weather-detail.component.ts @@ -1,4 +1,15 @@ -import {ChangeDetectionStrategy, Component, OnDestroy, OnInit, signal, ViewChild, WritableSignal} from '@angular/core'; +import { + AfterViewInit, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + inject, + OnDestroy, + OnInit, + signal, + ViewChild, + WritableSignal +} from '@angular/core'; import {MatFormField, MatPrefix, MatSuffix} from "@angular/material/form-field"; import {MatInput} from "@angular/material/input"; import {MatButton} from "@angular/material/button"; @@ -45,23 +56,29 @@ import moment from "moment"; templateUrl: './weather-detail.component.html', styleUrl: './weather-detail.component.css' }) -export class WeatherDetailComponent implements OnInit, OnDestroy { +export class WeatherDetailComponent implements OnInit, OnDestroy, AfterViewInit { @ViewChild(WeatherGraphComponent) weatherGraphComponent!: WeatherGraphComponent; + @ViewChild("saveButton") saveButton!: HTMLButtonElement; protected cityFormControl = new FormControl(); protected currentWeather: WritableSignal = signal(CurrentWeatherDetail.createDefault()) protected isUserSignedIn: WritableSignal = signal(false) protected readonly moment = moment; - private subscriptions: Subscription[] = []; - constructor(private weatherService: WeatherService, - private notificationService: NotificationService, - private authService: AuthService) { - } + private subscriptions: Subscription[] = []; + private weatherService = inject(WeatherService) + private notificationService = inject(NotificationService) + private authService = inject(AuthService) + private changeDetectorRef = inject(ChangeDetectorRef) ngOnInit(): void { this.isUserSignedIn.set(this.authService.isSignedIn()) } + ngAfterViewInit(): void { + this.changeSaveButtonState(true) + this.changeDetectorRef.detectChanges() + } + ngOnDestroy(): void { this.subscriptions.forEach(subscription => subscription.unsubscribe()); } @@ -77,13 +94,22 @@ export class WeatherDetailComponent implements OnInit, OnDestroy { this.subscriptions.push(this.weatherService.saveUserLocation(this.cityFormControl.value).subscribe({ next: () => { this.notificationService.successNotification('City saved') + this.changeSaveButtonState(true) }, error: () => { - this.notificationService.errorNotification('The city cannot be saved') + this.changeSaveButtonState(true) + this.notificationService.errorNotification('The city is already saved') } })) } + private changeSaveButtonState(state: boolean) { + if (this.isUserSignedIn()) { + this.saveButton.disabled = state + this.changeDetectorRef.detectChanges() + } + } + private getCurrentWeather() { this.subscriptions.push(this.weatherService.getCurrentWeather(this.cityFormControl.value).subscribe({ next: (response) => { @@ -98,9 +124,11 @@ export class WeatherDetailComponent implements OnInit, OnDestroy { private getForecastWeather() { this.subscriptions.push(this.weatherService.getForecastWeather(this.cityFormControl.value).subscribe({ next: (response) => { + this.changeSaveButtonState(false) this.weatherGraphComponent.createChart(response) }, error: () => { + this.changeSaveButtonState(true) this.notificationService.errorNotification('City not found') } })) diff --git a/frontend/src/app/weather/weather-list/weather-list.component.html b/frontend/src/app/weather/weather-list/weather-list.component.html index 1dafac9..03970d4 100644 --- a/frontend/src/app/weather/weather-list/weather-list.component.html +++ b/frontend/src/app/weather/weather-list/weather-list.component.html @@ -1,69 +1,67 @@ -
-
-
- - - - - {{ i }} - +
+
+ + + + + {{ i }} + - - Location - {{ element.location }} - + + Location + {{ element.location }} + - - Current weather - - - - + + Show weather + + + + - - Forecast - - - - + + Delete location + + + + - - - - - - - - Current weather - - brightness_5 - brightness_1 - - -
-

Date: {{ moment(currentWeather().time).format("DD-MM-YYYY") }}

-

Time: {{ moment(currentWeather().time).format("HH:MM") }}

-

Temperature: {{ currentWeather().temperature }} °C

-

Cloud cover: {{ currentWeather().cloudCover }} %

-

Wind speed: {{ currentWeather().temperature }} km/h

-
-
-
- - Graph of forecast weather - - brightness_5 - brightness_1 - - - - - -
-
+ + + + +
+
+ + Current weather + + brightness_5 + brightness_1 + + +
+

Date: {{ moment(currentWeather().time).format("HH:MM DD-MM-YYYY") }}

+

Temperature: {{ currentWeather().temperature }} °C

+

Cloud cover: {{ currentWeather().cloudCover }} %

+

Wind speed: {{ currentWeather().temperature }} km/h

+
+
+
+
+
+ + Graph of forecast weather + + brightness_5 + brightness_1 + + + + +
diff --git a/frontend/src/app/weather/weather-list/weather-list.component.ts b/frontend/src/app/weather/weather-list/weather-list.component.ts index d82fdc7..1329d95 100644 --- a/frontend/src/app/weather/weather-list/weather-list.component.ts +++ b/frontend/src/app/weather/weather-list/weather-list.component.ts @@ -64,7 +64,7 @@ export class WeatherListComponent implements OnInit, OnDestroy { @ViewChild(WeatherGraphComponent) weatherGraphComponent!: WeatherGraphComponent; protected weatherLocations: WritableSignal = signal([]) protected currentWeather: WritableSignal = signal(CurrentWeatherDetail.createDefault()) - protected displayedColumns: string[] = ['id', 'location', 'current', 'forecast']; + protected displayedColumns: string[] = ['id', 'location', 'show', 'delete']; protected readonly moment = moment; private weatherService = inject(WeatherService); private notificationService = inject(NotificationService) @@ -81,7 +81,7 @@ export class WeatherListComponent implements OnInit, OnDestroy { this.subscriptions.forEach(sub => sub.unsubscribe()); } - protected showCurrentWeather(location: string) { + protected showWeather(location: string) { this.subscriptions.push(this.weatherService.getCurrentWeather(location).subscribe({ next: (response) => { this.currentWeather.set(response) @@ -90,9 +90,6 @@ export class WeatherListComponent implements OnInit, OnDestroy { this.notificationService.errorNotification('City not found') } })) - } - - protected showForecastWeather(location: string) { this.subscriptions.push(this.weatherService.getForecastWeather(location).subscribe({ next: (response) => { this.weatherGraphComponent.createChart(response) @@ -103,6 +100,17 @@ export class WeatherListComponent implements OnInit, OnDestroy { })) } + protected deleteUserWeatherLocation(id: number) { + this.subscriptions.push(this.weatherService.deleteUserWeatherLocation(id).subscribe({ + next: () => { + this.loadLocations() + }, + error: () => { + this.notificationService.errorNotification('City not found') + } + })) + } + private loadLocations() { this.subscriptions.push(this.weatherService.getUserWeatherLocations().subscribe((response) => { this.weatherLocations.set(response); diff --git a/frontend/src/environments/environment.development.ts b/frontend/src/environments/environment.development.ts index f490dfe..c48cca3 100644 --- a/frontend/src/environments/environment.development.ts +++ b/frontend/src/environments/environment.development.ts @@ -1,6 +1,5 @@ export const environment = { baseUrl: 'http://localhost:8080/', production: false, - version: '0.0.1', - sentryDsn: '', + version: '0.0.1' }; diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts index 7bdbae8..44b1c85 100644 --- a/frontend/src/environments/environment.ts +++ b/frontend/src/environments/environment.ts @@ -1,6 +1,5 @@ export const environment = { baseUrl: '', production: false, - version: '0.0.1', - sentryDsn: '', // do not use Sentry + version: '0.0.1' }; diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 5998993..e845428 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -19,35 +19,44 @@ body { font-family: Roboto, "Helvetica Neue", sans-serif; } -.flex-container .col { +.container { + width: 100%; + align-items: stretch; display: flex; - flex-flow: column wrap; - padding-top: 1em; + justify-content: center; + flex-flow: row wrap; } -.flex-container .row { - display: flex; - flex-flow: row wrap; - column-gap: 1rem; - padding-top: 1em; +form { + width: 100%; } -.flex-container-end { - justify-content: flex-end; - align-items: center; - margin: 1em auto; +.content { + display: flex; + margin: 1em; } -.flex-container-start { - justify-content: flex-start; +.mat-form-field { + width: 100%; } -.flex-container-center { - justify-content: center; - align-items: center; - margin: 1em auto; +.mat-raised-button { + width: 100%; + height: 60px; + margin-top: 15px; } .mat-mdc-card-subtitle { color: black !important; } + +.mat-mdc-card { + background: white; + padding: 1em; + width: 350px; +} + +.mat-card-title { + font-size: 1.5em; + font-weight: bold; +} diff --git a/frontend/src/test/enviroments/enviroments.development.spec.ts b/frontend/src/test/enviroments/enviroments.development.spec.ts index 0931b4d..29341de 100644 --- a/frontend/src/test/enviroments/enviroments.development.spec.ts +++ b/frontend/src/test/enviroments/enviroments.development.spec.ts @@ -12,8 +12,4 @@ describe('Development Environment Configuration', () => { it('should have version set to 0.0.1 for development', () => { expect(environment.version).toBe('0.0.1'); }); - - it('should have empty sentryDsn for development', () => { - expect(environment.sentryDsn).toBe(''); - }); }); diff --git a/frontend/src/test/weather/weather-detail.component.spec.ts b/frontend/src/test/weather/weather-detail.component.spec.ts index b33ab8d..0f7cbc6 100644 --- a/frontend/src/test/weather/weather-detail.component.spec.ts +++ b/frontend/src/test/weather/weather-detail.component.spec.ts @@ -132,10 +132,12 @@ describe('WeatherDetailComponent', () => { ); weatherService.getForecastWeather = jest.fn().mockReturnValue(of(response)); + component['changeSaveButtonState'] = jest.fn(); component['getForecastWeather'](); expect(weatherService.getForecastWeather).toHaveBeenCalledWith("Test"); + expect(component['changeSaveButtonState']).toHaveBeenCalledWith(false); }); it("should show error notification when city is not found", () => { @@ -151,4 +153,62 @@ describe('WeatherDetailComponent', () => { expect(notificationService.errorNotification).toHaveBeenCalledWith('City not found'); }); }) + + describe("saveLocation", () => { + it('should save location', () => { + component['cityFormControl'].setValue("Test"); + + weatherService.saveUserLocation = jest.fn().mockReturnValue(of(true)); + notificationService.successNotification = jest.fn(); + component['changeSaveButtonState'] = jest.fn(); + + component['saveLocation'](); + + expect(weatherService.saveUserLocation).toHaveBeenCalledWith("Test"); + expect(notificationService.successNotification).toHaveBeenCalledWith('City saved'); + expect(component['changeSaveButtonState']).toHaveBeenCalledWith(true); + }); + + it('should show error notification when city is already saved', () => { + component['cityFormControl'].setValue("Test"); + + weatherService.saveUserLocation = jest.fn().mockReturnValue(throwError(() => ({status: 500}))); + notificationService.errorNotification = jest.fn(); + component['changeSaveButtonState'] = jest.fn(); + + component['saveLocation'](); + + expect(weatherService.saveUserLocation).toHaveBeenCalledWith("Test"); + expect(notificationService.errorNotification).toHaveBeenCalledWith('The city is already saved'); + expect(component['changeSaveButtonState']).toHaveBeenCalledWith(true); + + }); + }) + + describe("changeSaveButtonState", () => { + beforeEach(() => { + component['saveButton'] = document.createElement('button'); + component['changeDetectorRef'].detectChanges = jest.fn(); + }) + + it("should change save button state", () => { + component['isUserSignedIn'].set(true); + component['saveButton'].disabled = false; + + component['changeSaveButtonState'](true); + + expect(component['saveButton'].disabled).toEqual(true); + expect(component['changeDetectorRef'].detectChanges).toHaveBeenCalled(); + }); + + it("should not change save button state", () => { + component['isUserSignedIn'].set(false); + component['saveButton'].disabled = false; + + component['changeSaveButtonState'](true); + + expect(component['saveButton'].disabled).toEqual(false); + expect(component['changeDetectorRef'].detectChanges).not.toHaveBeenCalled(); + }); + }); }); diff --git a/frontend/src/test/weather/weather-list.component.spec.ts b/frontend/src/test/weather/weather-list.component.spec.ts index bd6b1cd..78670a1 100644 --- a/frontend/src/test/weather/weather-list.component.spec.ts +++ b/frontend/src/test/weather/weather-list.component.spec.ts @@ -62,9 +62,9 @@ describe('WeatherListComponent', () => { }); }) - describe("showForecastWeather", () => { + describe("showWeather", () => { it("should show current weather", () => { - const response = new CurrentWeatherDetail( + const currentWeatherDetail = new CurrentWeatherDetail( new Date(), 20, 50, @@ -72,12 +72,21 @@ describe('WeatherListComponent', () => { true ); - weatherService.getCurrentWeather = jest.fn().mockReturnValue(of(response)); + const forecastWeatherDetail = new ForecastWeatherDetail( + [new Date()], + [20], + [50], + [50] + ); + + weatherService.getCurrentWeather = jest.fn().mockReturnValue(of(currentWeatherDetail)); + weatherService.getForecastWeather = jest.fn().mockReturnValue(of(forecastWeatherDetail)); - component['showCurrentWeather']('test') + component['showWeather']('test') expect(weatherService.getCurrentWeather).toHaveBeenCalledWith("test"); - expect(component['currentWeather']()).toEqual(response); + expect(weatherService.getForecastWeather).toHaveBeenCalledWith("test"); + expect(component['currentWeather']()).toEqual(currentWeatherDetail); }); it("should show error notification when city is not found", () => { @@ -85,39 +94,39 @@ describe('WeatherListComponent', () => { component['currentWeather'].set(defaultWeather); weatherService.getCurrentWeather = jest.fn().mockReturnValue(throwError(() => ({status: 500}))); + weatherService.getForecastWeather = jest.fn().mockReturnValue(throwError(() => ({status: 500}))); notificationService.errorNotification = jest.fn(); - component['showCurrentWeather']('test') + component['showWeather']('test') expect(weatherService.getCurrentWeather).toHaveBeenCalledWith("test"); expect(component['currentWeather']()).toEqual(defaultWeather); expect(notificationService.errorNotification).toHaveBeenCalledWith('City not found'); + expect(weatherService.getForecastWeather).toHaveBeenCalledWith("test"); + expect(notificationService.errorNotification).toHaveBeenCalledWith('City not found'); }); }); - describe("showCurrentWeather", () => { - it("should show forecast weather", () => { - const response = new ForecastWeatherDetail( - [new Date()], - [20], - [50], - [50] - ); - - weatherService.getForecastWeather = jest.fn().mockReturnValue(of(response)); + describe("deleteUserWeatherLocation", () => { + it('should delete location and loadLocations', () => { + const locations = [new WeatherLocation(1, 'Test')] + weatherService.getUserWeatherLocations = jest.fn().mockReturnValue(of(locations)); + weatherService.deleteUserWeatherLocation = jest.fn().mockReturnValue(of(true)) - component['showForecastWeather']('test'); + component['deleteUserWeatherLocation'](1); - expect(weatherService.getForecastWeather).toHaveBeenCalledWith("test"); + expect(weatherService.deleteUserWeatherLocation).toHaveBeenCalledWith(1); + expect(weatherService.getUserWeatherLocations).toHaveBeenCalled(); + expect(component['weatherLocations']()).toEqual(locations); }); - it("should show error notification when city is not found", () => { - weatherService.getForecastWeather = jest.fn().mockReturnValue(throwError(() => ({status: 500}))); + it('should show error notification when city is not found', () => { + weatherService.deleteUserWeatherLocation = jest.fn().mockReturnValue(throwError(() => ({status: 500}))); notificationService.errorNotification = jest.fn(); - component['showForecastWeather']('test'); + component['deleteUserWeatherLocation'](1); - expect(weatherService.getForecastWeather).toHaveBeenCalledWith("test"); + expect(weatherService.deleteUserWeatherLocation).toHaveBeenCalledWith(1); expect(notificationService.errorNotification).toHaveBeenCalledWith('City not found'); }); })