diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index eb589c0..e333811 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -41,4 +41,6 @@ jobs: - name: Test with the dotnet CLI run: dotnet test - name: Test JS - run: echo "Hello" + run: | + cd src/storeonwheels.client + npm run test-ci diff --git a/Makefile b/Makefile index 3636de1..b99113a 100644 --- a/Makefile +++ b/Makefile @@ -8,3 +8,7 @@ start: test: dotnet test cd src/storeonwheels.client && npm run test + +format: + dotnet format --diagnostics --severity info + cd src/storeonwheels.client && npm run fmt \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Controllers/Geohubs/GeohubsClient.cs b/src/StoreOnWheels.Server/Controllers/Geohubs/GeohubsClient.cs index 918a01d..6f285e5 100644 --- a/src/StoreOnWheels.Server/Controllers/Geohubs/GeohubsClient.cs +++ b/src/StoreOnWheels.Server/Controllers/Geohubs/GeohubsClient.cs @@ -58,4 +58,4 @@ public override async Task OnDisconnectedAsync(Exception? exception) { await base.OnDisconnectedAsync(exception); } -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Controllers/Geohubs/IGeoHubClient.cs b/src/StoreOnWheels.Server/Controllers/Geohubs/IGeoHubClient.cs index 9d086f6..5d4093b 100644 --- a/src/StoreOnWheels.Server/Controllers/Geohubs/IGeoHubClient.cs +++ b/src/StoreOnWheels.Server/Controllers/Geohubs/IGeoHubClient.cs @@ -2,4 +2,4 @@ public interface IGeoHubClient { Task MessageReceived(string userId, string message); -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Controllers/Geohubs/MockPositionEmitter.cs b/src/StoreOnWheels.Server/Controllers/Geohubs/MockPositionEmitter.cs index 6b4db4a..e4e7465 100644 --- a/src/StoreOnWheels.Server/Controllers/Geohubs/MockPositionEmitter.cs +++ b/src/StoreOnWheels.Server/Controllers/Geohubs/MockPositionEmitter.cs @@ -35,5 +35,4 @@ private GeolocationPosition MockPosition(int index) { } }; } -} - +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Controllers/Healthchecks/HealthchecksController.cs b/src/StoreOnWheels.Server/Controllers/Healthchecks/HealthchecksController.cs index 1cea6c1..9fa1867 100644 --- a/src/StoreOnWheels.Server/Controllers/Healthchecks/HealthchecksController.cs +++ b/src/StoreOnWheels.Server/Controllers/Healthchecks/HealthchecksController.cs @@ -10,4 +10,4 @@ public ActionResult Get() { var payload = new { Message = "Server is up and running" }; return Ok(payload); } -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Controllers/Vendors/VendorsController.cs b/src/StoreOnWheels.Server/Controllers/Vendors/VendorsController.cs index 3653045..9b5f238 100644 --- a/src/StoreOnWheels.Server/Controllers/Vendors/VendorsController.cs +++ b/src/StoreOnWheels.Server/Controllers/Vendors/VendorsController.cs @@ -27,4 +27,4 @@ public async Task> Create([FromBody] Vendor vendor) { Vendor createdVendor = await vendorService.Create(vendor); return Created("api/v1/vendors", createdVendor); } -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Libs/Shared/Configs/AppDbContext.cs b/src/StoreOnWheels.Server/Libs/Shared/Configs/AppDbContext.cs index daf4f6b..f1fb20f 100644 --- a/src/StoreOnWheels.Server/Libs/Shared/Configs/AppDbContext.cs +++ b/src/StoreOnWheels.Server/Libs/Shared/Configs/AppDbContext.cs @@ -21,4 +21,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasData(vendor); } -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationCoordinate.cs b/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationCoordinate.cs index 927df15..7f9e03d 100644 --- a/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationCoordinate.cs +++ b/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationCoordinate.cs @@ -8,4 +8,4 @@ public class GeolocationCoordinate { public float Accuracy { get; set; } public float Altitude { get; set; } public float AltitudeAccuracy { get; set; } -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationPosition.cs b/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationPosition.cs index 1fef082..20a66f4 100644 --- a/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationPosition.cs +++ b/src/StoreOnWheels.Server/Libs/Shared/Models/GeolocationPosition.cs @@ -12,4 +12,4 @@ public class GeolocationPosition { public string ToJson() { return JsonConvert.SerializeObject(this, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); } -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Libs/Vendors/IVendorService.cs b/src/StoreOnWheels.Server/Libs/Vendors/IVendorService.cs index 4df443b..ef9b2ae 100644 --- a/src/StoreOnWheels.Server/Libs/Vendors/IVendorService.cs +++ b/src/StoreOnWheels.Server/Libs/Vendors/IVendorService.cs @@ -7,4 +7,4 @@ public interface IVendorService { Task GetByName(string displayName); Task Create(Vendor vendor); Task Delete(string vendorId); -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Libs/Vendors/VendorService.cs b/src/StoreOnWheels.Server/Libs/Vendors/VendorService.cs index 2a8edbd..5fdeb58 100644 --- a/src/StoreOnWheels.Server/Libs/Vendors/VendorService.cs +++ b/src/StoreOnWheels.Server/Libs/Vendors/VendorService.cs @@ -21,4 +21,4 @@ public async Task Delete(string vendorId) { db.Vendors.Remove(vendor); await db.SaveChangesAsync(); } -} +} \ No newline at end of file diff --git a/src/StoreOnWheels.Server/Migrations/20240427121321_InitialVendorDb.cs b/src/StoreOnWheels.Server/Migrations/20240427121321_InitialVendorDb.cs index 12f17a8..ab741b9 100644 --- a/src/StoreOnWheels.Server/Migrations/20240427121321_InitialVendorDb.cs +++ b/src/StoreOnWheels.Server/Migrations/20240427121321_InitialVendorDb.cs @@ -5,6 +5,8 @@ namespace StoreOnWheels.Server.Migrations { /// public partial class InitialVendorDb : Migration { + private static readonly string[] columns = ["Id", "Description", "DisplayName"]; + /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( @@ -20,7 +22,7 @@ protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.InsertData( table: "Vendors", - columns: new[] { "Id", "Description", "DisplayName" }, + columns: columns, values: new object[] { "1", "Some food truck", "FoodTruck 1" }); migrationBuilder.CreateIndex( @@ -36,4 +38,4 @@ protected override void Down(MigrationBuilder migrationBuilder) { name: "Vendors"); } } -} +} \ No newline at end of file diff --git a/src/storeonwheels.client/package.json b/src/storeonwheels.client/package.json index c1ade31..4ecfc1f 100644 --- a/src/storeonwheels.client/package.json +++ b/src/storeonwheels.client/package.json @@ -7,6 +7,7 @@ "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", + "test-ci": "ng test --browsers=ChromeHeadless --watch=false", "prestart": "node aspnetcore-https", "start:windows": "ng serve --ssl --ssl-cert \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem\" --ssl-key \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.key\"", "start:default": "ng serve --ssl --ssl-cert \"$HOME/.aspnet/https/${npm_package_name}.pem\" --ssl-key \"$HOME/.aspnet/https/${npm_package_name}.key\"", diff --git a/src/storeonwheels.client/src/app/app.component.spec.ts b/src/storeonwheels.client/src/app/app.component.spec.ts deleted file mode 100644 index d30fe1a..0000000 --- a/src/storeonwheels.client/src/app/app.component.spec.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { - HttpTestingController, - provideHttpClientTesting, -} from "@angular/common/http/testing"; -import { ComponentFixture, TestBed } from "@angular/core/testing"; -import { AppComponent } from "./app.component"; -import { - provideHttpClient, - withInterceptorsFromDi, -} from "@angular/common/http"; - -describe("AppComponent", () => { - let component: AppComponent; - let fixture: ComponentFixture; - let httpMock: HttpTestingController; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [AppComponent], - imports: [], - providers: [ - provideHttpClient(withInterceptorsFromDi()), - provideHttpClientTesting(), - ], - }).compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(AppComponent); - component = fixture.componentInstance; - httpMock = TestBed.inject(HttpTestingController); - }); - - afterEach(() => { - httpMock.verify(); - }); - - it("should create the app", () => { - expect(component).toBeTruthy(); - }); - - it("should retrieve weather forecasts from the server", () => { - const mockForecasts = [ - { - date: "2021-10-01", - temperatureC: 20, - temperatureF: 68, - summary: "Mild", - }, - { - date: "2021-10-02", - temperatureC: 25, - temperatureF: 77, - summary: "Warm", - }, - ]; - - //component.ngOnInit(); - - const req = httpMock.expectOne("/weatherforecast"); - expect(req.request.method).toEqual("GET"); - req.flush(mockForecasts); - }); -}); diff --git a/src/storeonwheels.client/src/app/libs/broadcast/components/geo-permission-instruction/geo-permission-instruction.component.spec.ts b/src/storeonwheels.client/src/app/libs/broadcast/components/geo-permission-instruction/geo-permission-instruction.component.spec.ts index b7bf954..2f8408a 100644 --- a/src/storeonwheels.client/src/app/libs/broadcast/components/geo-permission-instruction/geo-permission-instruction.component.spec.ts +++ b/src/storeonwheels.client/src/app/libs/broadcast/components/geo-permission-instruction/geo-permission-instruction.component.spec.ts @@ -1,10 +1,11 @@ import { ComponentFixture, TestBed } from "@angular/core/testing"; - import { GeoPermissionInstructionComponent } from "./geo-permission-instruction.component"; describe("GeoPermissionComponent", () => { let component: GeoPermissionInstructionComponent; let fixture: ComponentFixture; + const instructions: RegExp = + /To modify permission, click the map marker icon at the address bar/i; beforeEach(async () => { await TestBed.configureTestingModule({ @@ -13,10 +14,21 @@ describe("GeoPermissionComponent", () => { fixture = TestBed.createComponent(GeoPermissionInstructionComponent); component = fixture.componentInstance; - fixture.detectChanges(); + fixture.autoDetectChanges(); + }); + + it("prompt geoPermission should not show instructions", async () => { + expect(component).toBeTruthy(); + fixture.componentRef.setInput("geoPermission", "prompt"); + await fixture.detectChanges(); + const root: HTMLElement = fixture.nativeElement; + expect(root.innerText).not.toMatch(instructions); }); - it("should create", () => { + it("granted geoPermission should show instructions", () => { expect(component).toBeTruthy(); + fixture.componentRef.setInput("geoPermission", "granted"); + const root: HTMLElement = fixture.nativeElement; + expect(root.innerText).toMatch(instructions); }); }); diff --git a/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.html b/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.html index c99ec33..56ba683 100644 --- a/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.html +++ b/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.html @@ -1,14 +1,20 @@ -@if (vendorForm) { +@if (vendorForm && displayName && description) {
Name + @if (displayName.invalid && (displayName.touched || displayName.dirty)) { +

Name is required

+ } Description + @if (description.invalid && (description.touched || description.dirty)) { +

Description is required

+ } diff --git a/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.spec.ts b/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.spec.ts index ea7a92b..9e36217 100644 --- a/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.spec.ts +++ b/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.spec.ts @@ -1,22 +1,77 @@ -import { ComponentFixture, TestBed } from "@angular/core/testing"; - +import { + ComponentFixture, + TestBed, + ComponentFixtureAutoDetect, +} from "@angular/core/testing"; import { VendorFormComponent } from "./vendor-form.component"; +import { FormBuilder, FormGroup, Validators } from "@angular/forms"; +import { VendorForm } from "~/app/libs/shared/models"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; describe("VendorFormComponent", () => { let component: VendorFormComponent; let fixture: ComponentFixture; beforeEach(async () => { + const formBuilder = new FormBuilder(); + const vendorForm: FormGroup = formBuilder.nonNullable.group({ + id: ["", Validators.required], + displayName: ["", Validators.required], + description: ["", Validators.required], + }); + await TestBed.configureTestingModule({ - imports: [VendorFormComponent], + imports: [VendorFormComponent, BrowserAnimationsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], }).compileComponents(); fixture = TestBed.createComponent(VendorFormComponent); + fixture.componentRef.setInput("vendorForm", vendorForm); + fixture.autoDetectChanges(); + component = fixture.componentInstance; - fixture.detectChanges(); }); it("should create", () => { expect(component).toBeTruthy(); }); + + it("labels should exists", () => { + fixture.detectChanges(); + const root: HTMLElement = fixture.nativeElement; + expect(root).toBeTruthy(); + + const labels: HTMLLabelElement[] = Array.from( + root.querySelectorAll("label") + ); + expect(labels.length).toBe(2); + expect(labels[0].innerText).toBe("Name"); + expect(labels[1].innerText).toBe("Description"); + }); + + it("validation should work", async () => { + const root: HTMLElement = fixture.nativeElement; + expect(root).toBeTruthy(); + expect(component.vendorForm).toBeTruthy(); + + component.vendorForm?.markAllAsTouched(); + fixture.detectChanges(); + expect(root.innerText).toContain("Name is required"); + expect(root.innerText).toContain("Description is required"); + + const nameInput: HTMLInputElement | null = root.querySelector("input"); + expect(nameInput).not.toBeNull(); + + if (nameInput == null) { + return; + } + + nameInput.value = "ABC"; + // Dispatch a DOM event so that Angular learns of input value change. + nameInput.dispatchEvent(new Event("input")); + // Wait for Angular to update the display binding + await fixture.whenStable(); + + expect(root.innerText).not.toContain("Name is required"); + }); }); diff --git a/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.ts b/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.ts index 833dbe5..42cd994 100644 --- a/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.ts +++ b/src/storeonwheels.client/src/app/libs/broadcast/components/vendor-form/vendor-form.component.ts @@ -1,6 +1,6 @@ -import { Component, Input, output } from "@angular/core"; +import { Component, Input, OnChanges, output } from "@angular/core"; import { VendorForm } from "~/app/libs/shared/models"; -import { FormGroup, ReactiveFormsModule } from "@angular/forms"; +import { FormControl, FormGroup, ReactiveFormsModule } from "@angular/forms"; import { MatFormFieldModule } from "@angular/material/form-field"; import { MatInputModule } from "@angular/material/input"; import { CommonModule } from "@angular/common"; @@ -17,15 +17,20 @@ import { CommonModule } from "@angular/common"; templateUrl: "./vendor-form.component.html", styleUrl: "./vendor-form.component.css", }) -export class VendorFormComponent { +export class VendorFormComponent implements OnChanges { @Input({ required: true }) vendorForm?: FormGroup; + displayName: FormControl | undefined; + description: FormControl | undefined; submitEvent = output(); + ngOnChanges() { + this.displayName = this.vendorForm?.controls.displayName; + this.description = this.vendorForm?.controls.description; + } + onSubmit() { if (this.vendorForm != null) { this.submitEvent.emit(Date.now()); } - - const x = 5 + 5; } } diff --git a/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts b/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts index ec5ae75..d1475d2 100644 --- a/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts +++ b/src/storeonwheels.client/src/app/libs/map/services/message-hub/message-hub.service.spec.ts @@ -8,9 +8,7 @@ describe("MessageHubService", () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [ - { provide: HUB_CONNECTION, useValue: hubConnection }, - ] + providers: [{ provide: HUB_CONNECTION, useValue: hubConnection }], }); service = TestBed.inject(MessageHubService); }); diff --git a/src/storeonwheels.client/src/app/libs/shared/components/footer-nav/footer-nav.component.spec.ts b/src/storeonwheels.client/src/app/libs/shared/components/footer-nav/footer-nav.component.spec.ts index 6610226..4e2c714 100644 --- a/src/storeonwheels.client/src/app/libs/shared/components/footer-nav/footer-nav.component.spec.ts +++ b/src/storeonwheels.client/src/app/libs/shared/components/footer-nav/footer-nav.component.spec.ts @@ -1,6 +1,6 @@ import { ComponentFixture, TestBed } from "@angular/core/testing"; - import { FooterNavComponent } from "./footer-nav.component"; +import { RouterModule } from "@angular/router"; describe("FooterNavComponent", () => { let component: FooterNavComponent; @@ -8,7 +8,7 @@ describe("FooterNavComponent", () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [FooterNavComponent], + imports: [FooterNavComponent, RouterModule.forRoot([])], }).compileComponents(); fixture = TestBed.createComponent(FooterNavComponent); @@ -18,5 +18,9 @@ describe("FooterNavComponent", () => { it("should create", () => { expect(component).toBeTruthy(); + + const root: HTMLElement = fixture.nativeElement; + expect(root.innerText).toMatch(/map/i); + expect(root.innerText).toMatch(/broadcast/i); }); }); diff --git a/src/storeonwheels.client/src/app/libs/shared/services/index.ts b/src/storeonwheels.client/src/app/libs/shared/services/index.ts index df5f7ce..6030039 100644 --- a/src/storeonwheels.client/src/app/libs/shared/services/index.ts +++ b/src/storeonwheels.client/src/app/libs/shared/services/index.ts @@ -1,2 +1 @@ -export * from "./math/math.service"; export * from "./sleep/sleep.service"; diff --git a/src/storeonwheels.client/src/app/libs/shared/services/math/math.service.spec.ts b/src/storeonwheels.client/src/app/libs/shared/services/math/math.service.spec.ts deleted file mode 100644 index 82a2bc1..0000000 --- a/src/storeonwheels.client/src/app/libs/shared/services/math/math.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from "@angular/core/testing"; - -import { MathService } from "./math.service"; - -describe("RandomService", () => { - let service: MathService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(MathService); - }); - - it("should be created", () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/src/storeonwheels.client/src/app/libs/shared/services/math/math.service.ts b/src/storeonwheels.client/src/app/libs/shared/services/math/math.service.ts deleted file mode 100644 index 2e3959d..0000000 --- a/src/storeonwheels.client/src/app/libs/shared/services/math/math.service.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Injectable } from "@angular/core"; - -@Injectable({ - providedIn: "root", -}) -export class MathService { - getRandomInt(min: number, max: number): number { - return Math.random() * (max - min) + min; - } -} diff --git a/src/storeonwheels.client/src/app/pages/broadcast-page/broadcast-page.component.spec.ts b/src/storeonwheels.client/src/app/pages/broadcast-page/broadcast-page.component.spec.ts index 8bba972..7a86ec0 100644 --- a/src/storeonwheels.client/src/app/pages/broadcast-page/broadcast-page.component.spec.ts +++ b/src/storeonwheels.client/src/app/pages/broadcast-page/broadcast-page.component.spec.ts @@ -1,22 +1,60 @@ import { ComponentFixture, TestBed } from "@angular/core/testing"; - import { BroadcastPageComponent } from "./broadcast-page.component"; +import axios from "axios"; +import { HUB_CONNECTION, hubConnection } from "~/app/libs/map/services"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; describe("BroadcastPageComponent", () => { let component: BroadcastPageComponent; let fixture: ComponentFixture; beforeEach(async () => { + spyOn(axios, "post").and.resolveTo({ data: {} }); + await TestBed.configureTestingModule({ - imports: [BroadcastPageComponent], + imports: [BroadcastPageComponent, BrowserAnimationsModule], + providers: [{ provide: HUB_CONNECTION, useValue: hubConnection }], }).compileComponents(); fixture = TestBed.createComponent(BroadcastPageComponent); component = fixture.componentInstance; - fixture.detectChanges(); + fixture.autoDetectChanges(); }); - it("should create", () => { - expect(component).toBeTruthy(); + it("form stepper should progress", async () => { + const root: HTMLElement = fixture.nativeElement; + expect(component.vendorForm).toBeTruthy(); + + fixture.detectChanges(); + const nameInput = Array.from(root.querySelectorAll("input")).find( + (el) => + el.attributes.getNamedItem("formcontrolname")?.value == "displayName" + ) as HTMLInputElement; + const descriptionInput = Array.from(root.querySelectorAll("input")).find( + (el) => + el.attributes.getNamedItem("formcontrolname")?.value == "description" + ) as HTMLInputElement; + expect(nameInput).not.toBeNull(); + expect(descriptionInput).not.toBeNull(); + + // Dispatch a DOM event so that Angular learns of input value change. + // Wait for Angular to update the display binding + nameInput.value = "MOCK_NAME"; + nameInput.dispatchEvent(new Event("input")); + descriptionInput.value = "MOCK_VALUE"; + descriptionInput.dispatchEvent(new Event("input")); + + await fixture.whenStable(); + + const button = Array.from(root.querySelectorAll("button")).find((el) => + el.innerText.includes("Next") + ) as HTMLInputElement; + expect(button).not.toBeNull(); + button.click(); + + await fixture.whenStable(); + + // Second step reached + expect(root.innerText).toContain("Reset"); }); }); diff --git a/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts b/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts index f4056b9..4166014 100644 --- a/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts +++ b/src/storeonwheels.client/src/app/pages/healthcheck-page/healthcheck-page.component.spec.ts @@ -1,22 +1,26 @@ import { ComponentFixture, TestBed } from "@angular/core/testing"; import axios from "axios"; import { HealthcheckComponent } from "./healthcheck-page.component"; -import { HUB_CONNECTION, MessageHubService, hubConnection } from "~/app/libs/map/services"; +import { + HUB_CONNECTION, + MessageHubService, + hubConnection, +} from "~/app/libs/map/services"; describe("HealthcheckComponent", () => { let component: HealthcheckComponent; let fixture: ComponentFixture; beforeEach(async () => { - const data: Record = { message: 'Server is running' }; - spyOn(axios, 'get').and.resolveTo({ data }); + const data: Record = { message: "Server is running" }; + spyOn(axios, "get").and.resolveTo({ data }); await TestBed.configureTestingModule({ imports: [HealthcheckComponent], providers: [ { provide: HUB_CONNECTION, useValue: hubConnection }, MessageHubService, - ] + ], }).compileComponents(); fixture = TestBed.createComponent(HealthcheckComponent); @@ -26,7 +30,7 @@ describe("HealthcheckComponent", () => { it("should create", () => expect(component).toBeTruthy()); - it("should display health status", async() => { + it("should display health status", async () => { const root: HTMLElement = fixture.nativeElement; fixture.detectChanges(); expect(root.innerText).toContain("Server is running"); diff --git a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestGeohubClient.cs b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestGeohubClient.cs index 94d9bb0..3d789d3 100644 --- a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestGeohubClient.cs +++ b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestGeohubClient.cs @@ -35,9 +35,9 @@ public async Task Broadcast_Vendor_Position_Annonymously_Should_Broadcast_Positi try { await connection.SendAsync("BroadcastVendorPositionAnonymously", "vendor1", str); } catch (Exception ex) { - Logger.WriteLine(ex.Message); + Logger.WriteLine(ex.Message); error = ex; } Assert.Null(error); } -} +} \ No newline at end of file diff --git a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestMockPositionEmitter.cs b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestMockPositionEmitter.cs index 10eac67..6bbdf21 100644 --- a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestMockPositionEmitter.cs +++ b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Geohubs/TestMockPositionEmitter.cs @@ -4,7 +4,7 @@ namespace StoreOnWheels.Server.Test.Integration.Controllers.Geohubs; public class TestMockPositionEmitter( - CustomWebAppFactory factory, + CustomWebAppFactory factory, ITestOutputHelper Logger ) : IClassFixture>, IAsyncLifetime { private record MessageInfo(string User, string Message); @@ -20,7 +20,7 @@ public async Task DisposeAsync() { } [Fact] - public async Task Mock_Vendor_Info_On_Connected() { + public async Task Mock_Vendor_Info_On_Connected() { Logger.WriteLine("Connection started successfully"); (string vendorId, string message) = await GetMessageInfoAsync(connection); Assert.NotEmpty(vendorId); @@ -39,4 +39,4 @@ private static Task GetMessageInfoAsync(HubConnection connection) { }); return infoTcs.Task; } -} +} \ No newline at end of file diff --git a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Healthchecks/TestHealthcheckController.cs b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Healthchecks/TestHealthcheckController.cs index 9be02aa..d9aa069 100644 --- a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Healthchecks/TestHealthcheckController.cs +++ b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Healthchecks/TestHealthcheckController.cs @@ -20,4 +20,4 @@ public async Task TestGet() { Assert.NotNull(result); Assert.Equal("Server is up and running", result["message"]); } -} +} \ No newline at end of file diff --git a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Vendors/TestVendorsController.cs b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Vendors/TestVendorsController.cs index aa72e50..48dae9e 100644 --- a/tests/StoreOnWheels.Server.Test.Integration/Controllers/Vendors/TestVendorsController.cs +++ b/tests/StoreOnWheels.Server.Test.Integration/Controllers/Vendors/TestVendorsController.cs @@ -30,4 +30,4 @@ public async Task Post_CreateVendor_ReturnsCreated() { Assert.NotNull(result); Assert.Equal(vendor.DisplayName, result.DisplayName); } -} +} \ No newline at end of file diff --git a/tests/StoreOnWheels.Server.Test.Integration/CustomWebAppFactory.cs b/tests/StoreOnWheels.Server.Test.Integration/CustomWebAppFactory.cs index a96b67d..17e23f6 100644 --- a/tests/StoreOnWheels.Server.Test.Integration/CustomWebAppFactory.cs +++ b/tests/StoreOnWheels.Server.Test.Integration/CustomWebAppFactory.cs @@ -22,10 +22,6 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.UseEnvironment("Development"); } - public new void Dispose() { - base.Dispose(); - } - // https://tinyurl.com/6ze2sweh private static void RemoveCurrentDb(IServiceCollection services) { ServiceDescriptor? dbContextDescriptor = services @@ -71,4 +67,4 @@ public HubConnection HubConnection() { }) .Build(); } -} +} \ No newline at end of file