From c1eedbf364486aabeb2c67774f139e77b7f2a942 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 20 Jan 2024 17:40:42 +0100 Subject: [PATCH 01/10] chore: build website preview when asyncapi.json changes --- netlify.toml | 15 +++++++++++++++ springwolf-ui/src/_redirects | 7 ------- 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 netlify.toml delete mode 100644 springwolf-ui/src/_redirects diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 000000000..5128bd589 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,15 @@ +[build] +base = "springwolf-ui" +publish = "springwolf-ui/dist/" +build = "ng build --base-href=/springwolf-ui/" +ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF springwolf-ui springwolf-examples/**/asyncapi.json" + +[[redirects]] +from = "/" +to = " /springwolf-ui/asyncapi-ui.html" +status = 301 + +[[redirects]] +from = "/springwolf-ui" +to = " /springwolf-ui/asyncapi-ui.html" +status = 301 diff --git a/springwolf-ui/src/_redirects b/springwolf-ui/src/_redirects deleted file mode 100644 index f6fc85662..000000000 --- a/springwolf-ui/src/_redirects +++ /dev/null @@ -1,7 +0,0 @@ -# Redirects from what the browser requests to what we serve -# Usage with netlify for dev build with mock data: -# Build command: ng build --base-href=/springwolf-ui/ && mv dist/springwolf-ui/_redirects dist/_redirects -# Publish directory: dist/ - -/ /springwolf-ui/asyncapi-ui.html -/springwolf-ui /springwolf-ui/asyncapi-ui.html From 19f945c853cda49abbe13bb6e48e1c66eef50d87 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 20 Jan 2024 17:47:03 +0100 Subject: [PATCH 02/10] chore: build website preview when asyncapi.json changes --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 5128bd589..4aa1cb8a2 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,6 @@ [build] base = "springwolf-ui" -publish = "springwolf-ui/dist/" +publish = "dist/" build = "ng build --base-href=/springwolf-ui/" ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF springwolf-ui springwolf-examples/**/asyncapi.json" From dc21ec8b51948d225f1743f62043c5546410bd46 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 20 Jan 2024 17:49:34 +0100 Subject: [PATCH 03/10] chore: build website preview when asyncapi.json changes --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 4aa1cb8a2..93f8a844d 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,7 @@ [build] base = "springwolf-ui" publish = "dist/" -build = "ng build --base-href=/springwolf-ui/" +command = "ng build --base-href=/springwolf-ui/" ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF springwolf-ui springwolf-examples/**/asyncapi.json" [[redirects]] From f54070e5707556b7270cdf2aefcd0cda6037b9b4 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 20 Jan 2024 17:59:55 +0100 Subject: [PATCH 04/10] chore: build website preview when asyncapi.json changes --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 93f8a844d..a5ed69539 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,7 +2,7 @@ base = "springwolf-ui" publish = "dist/" command = "ng build --base-href=/springwolf-ui/" -ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF springwolf-ui springwolf-examples/**/asyncapi.json" +ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ./ ../springwolf-examples/**/asyncapi.json" [[redirects]] from = "/" From d34ce28e5927aa5f72cf5e8c5df8f7293ae0591b Mon Sep 17 00:00:00 2001 From: Nikita Marunko Date: Mon, 29 Jan 2024 21:38:22 +0900 Subject: [PATCH 05/10] refactor(schema): correct margin and padding values Warnings are present Refs #378 --- .../app/components/schemas/range/schema-range.component.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/springwolf-ui/src/app/components/schemas/range/schema-range.component.css b/springwolf-ui/src/app/components/schemas/range/schema-range.component.css index e326ac5e4..a0e54bd82 100644 --- a/springwolf-ui/src/app/components/schemas/range/schema-range.component.css +++ b/springwolf-ui/src/app/components/schemas/range/schema-range.component.css @@ -2,7 +2,7 @@ .range { background-color: rgb(128, 90, 213); color: rgb(255, 255, 255); - margin: 0 8 0 8; - padding: 2 4 2 4; + margin: 0 8px 0 8px; + padding: 2px 4px 2px 4px; border-radius: 4px; } From b53de57884dbcbf2195bbc7cecae024f2539daf8 Mon Sep 17 00:00:00 2001 From: Nikita Marunko Date: Tue, 30 Jan 2024 21:14:26 +0900 Subject: [PATCH 06/10] test(ui): cover schema-range component 0 coverage Refs #378 --- .../range/schema-range.component.spec.ts | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 springwolf-ui/src/app/components/schemas/range/schema-range.component.spec.ts diff --git a/springwolf-ui/src/app/components/schemas/range/schema-range.component.spec.ts b/springwolf-ui/src/app/components/schemas/range/schema-range.component.spec.ts new file mode 100644 index 000000000..e16ca94cf --- /dev/null +++ b/springwolf-ui/src/app/components/schemas/range/schema-range.component.spec.ts @@ -0,0 +1,129 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { SchemaRangeComponent } from "./schema-range.component"; + +describe("SchemaRangeComponent", function () { + let component: SchemaRangeComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [SchemaRangeComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(SchemaRangeComponent as any); + component = fixture.debugElement.componentInstance; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); + + it("should have `( 0.1 .. 10 )` as value", async () => { + component.schema = { + title: "test", + minimum: 0.1, + maximum: 10, + exclusiveMinimum: true, + exclusiveMaximum: true, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain( + "( 0.1 .. 10 )" + ); + }); + + it("should have `[ 0.1 .. 10 )` as value", async () => { + component.schema = { + title: "test", + minimum: 0.1, + maximum: 10, + exclusiveMinimum: false, + exclusiveMaximum: true, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain( + "[ 0.1 .. 10 )" + ); + }); + + it("should have `( 0.1 .. 10 ]` as value", async () => { + component.schema = { + title: "test", + minimum: 0.1, + maximum: 10, + exclusiveMinimum: true, + exclusiveMaximum: false, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain( + "( 0.1 .. 10 ]" + ); + }); + + it("should have `[ 0.1 .. 10 ]` as value", async () => { + component.schema = { + title: "test", + minimum: 0.1, + maximum: 10, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain( + "[ 0.1 .. 10 ]" + ); + }); + + it("should have `> 0.1` as value", async () => { + component.schema = { + title: "test", + minimum: 0.1, + exclusiveMinimum: true, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain("> 0.1"); + }); + + it("should have `< 10` as value", async () => { + component.schema = { + title: "test", + maximum: 10, + exclusiveMaximum: true, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain("< 10"); + }); + + it("should have `>= 0.1` as value", async () => { + component.schema = { + title: "test", + minimum: 0.1, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain(">= 0.1"); + }); + + it("should have `<= 10` as value", async () => { + component.schema = { + title: "test", + maximum: 10, + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("span").textContent).toContain("<= 10"); + }); +}); From c9de230e88fa0371eac18fc952c42c774cba4c4b Mon Sep 17 00:00:00 2001 From: Nikita Marunko Date: Tue, 30 Jan 2024 21:34:50 +0900 Subject: [PATCH 07/10] refactor(ui): simplify schema range rendering Is difficult to maintain Refs #378 --- .../schemas/range/schema-range.component.html | 46 ++----------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/springwolf-ui/src/app/components/schemas/range/schema-range.component.html b/springwolf-ui/src/app/components/schemas/range/schema-range.component.html index 61773d918..58dfa4ac8 100644 --- a/springwolf-ui/src/app/components/schemas/range/schema-range.component.html +++ b/springwolf-ui/src/app/components/schemas/range/schema-range.component.html @@ -4,56 +4,18 @@ class="range" *ngIf="schema.minimum !== undefined && schema.maximum === undefined" > - - {{ schema.minimum }} + {{ schema.exclusiveMinimum ? ">" : ">=" }} {{ schema.minimum }} - - {{ schema.maximum }} + {{ schema.exclusiveMaximum ? "<" : "<=" }} {{ schema.maximum }} {{ schema.exclusiveMinimum ? "(" : "[" }} {{ schema.minimum }} .. + {{ schema.maximum }} {{ schema.exclusiveMaximum ? ")" : "]" }} - - {{ schema.minimum }} .. {{ schema.maximum }} - - - -( -) -[ -] - -> -< ->= -<= From e1e38babc453353393e52e449b38bf729186c098 Mon Sep 17 00:00:00 2001 From: Nikita Marunko Date: Wed, 6 Mar 2024 22:20:50 +0900 Subject: [PATCH 08/10] test(ui): cover info component Refs #378 --- .../components/info/info.component.spec.ts | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 springwolf-ui/src/app/components/info/info.component.spec.ts diff --git a/springwolf-ui/src/app/components/info/info.component.spec.ts b/springwolf-ui/src/app/components/info/info.component.spec.ts new file mode 100644 index 000000000..f3f6ac1e5 --- /dev/null +++ b/springwolf-ui/src/app/components/info/info.component.spec.ts @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import {ComponentFixture, TestBed} from "@angular/core/testing"; +import {InfoComponent} from "./info.component"; +import {AsyncApiService} from "../../service/asyncapi/asyncapi.service"; +import {of} from "rxjs/internal/observable/of"; +import {MatChipsModule} from "@angular/material/chips"; +import {MarkdownModule} from "ngx-markdown"; + +describe("InfoComponent", function () { + let component: InfoComponent; + let fixture: ComponentFixture; + + let mockedAsyncApiService!: { getAsyncApi: jest.Mock }; + + let info = { + title: "title", + version: "1.0.0", + description: "example", + contact: { + url: "https://test.com", + email: { + name: "springwolf", + href: "link" + } + }, + license: { + name: "Apache License 2.0" + }, + asyncApiJson: null, + } + + beforeEach(() => { + mockedAsyncApiService = { + getAsyncApi: jest.fn(), + }; + + TestBed.configureTestingModule({ + declarations: [InfoComponent], + imports: [MatChipsModule, MarkdownModule.forRoot()], + providers: [ + {provide: AsyncApiService, useValue: mockedAsyncApiService}, + ], + }).compileComponents(); + + fixture = TestBed.createComponent(InfoComponent as any); + component = fixture.debugElement.componentInstance; + component.info = info; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); + + it("should render the title", async () => { + mockedAsyncApiService.getAsyncApi.mockReturnValue(of()); + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("h1").textContent).toContain( + "title" + ); + expect(compiled.querySelector("h5").textContent).toContain( + " API version 1.0.0 - Download AsyncAPI file" + ); + }); + + it("should render the license information", async () => { + mockedAsyncApiService.getAsyncApi.mockReturnValue(of()); + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector("p").textContent).toContain( + "License: Apache License 2.0 https://test.com springwolf " + ); + }); + +}); + From 54b799e58d8210c59a3656e9157ce95865750656 Mon Sep 17 00:00:00 2001 From: Nikita Marunko Date: Wed, 27 Mar 2024 22:52:37 +0900 Subject: [PATCH 09/10] test(ui): cover all components Are absent Refs #378 --- .../channel-main.component.spec.ts | 46 ++++++++++++++++++ .../channels/channels.component.spec.ts | 30 ++++++++++++ .../header/header.component.spec.ts | 23 +++++++++ .../components/info/info.component.spec.ts | 28 +++++------ .../schemas/schema/schema.component.spec.ts | 47 +++++++++++++++++++ .../schemas/schemas.component.spec.ts | 30 ++++++++++++ .../servers/servers.component.spec.ts | 27 +++++++++++ 7 files changed, 215 insertions(+), 16 deletions(-) create mode 100644 springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts create mode 100644 springwolf-ui/src/app/components/channels/channels.component.spec.ts create mode 100644 springwolf-ui/src/app/components/header/header.component.spec.ts create mode 100644 springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts create mode 100644 springwolf-ui/src/app/components/schemas/schemas.component.spec.ts create mode 100644 springwolf-ui/src/app/components/servers/servers.component.spec.ts diff --git a/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts new file mode 100644 index 000000000..45ddb6fd0 --- /dev/null +++ b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { AsyncApiService } from "../../../service/asyncapi/asyncapi.service"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { ChannelMainComponent } from "./channel-main.component"; +import { PublisherService } from "../../../service/publisher.service"; +import { MatDivider } from "@angular/material/divider"; +import { MatTab, MatTabGroup, MatTabHeader } from "@angular/material/tabs"; +import { JsonComponent } from "../../json/json.component"; +import { MarkdownModule } from "ngx-markdown"; + +describe("ChannelMainComponent", () => { + let component: ChannelMainComponent; + let fixture: ComponentFixture; + + let mockedAsyncApiService = { + getAsyncApi: jest.fn(), + }; + let mockedPublisherService = { + getAsyncApi: jest.fn(), + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ + ChannelMainComponent, + JsonComponent, + MatDivider, + MatTabGroup, + MatTab, + MatTabHeader, + ], + imports: [MarkdownModule.forRoot()], + providers: [ + { provide: AsyncApiService, useValue: mockedAsyncApiService }, + { provide: PublisherService, useValue: mockedPublisherService }, + ], + }).compileComponents(); + + fixture = TestBed.createComponent(ChannelMainComponent as any); + component = fixture.debugElement.componentInstance; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/springwolf-ui/src/app/components/channels/channels.component.spec.ts b/springwolf-ui/src/app/components/channels/channels.component.spec.ts new file mode 100644 index 000000000..0f6e97dd3 --- /dev/null +++ b/springwolf-ui/src/app/components/channels/channels.component.spec.ts @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { AsyncApiService } from "../../service/asyncapi/asyncapi.service"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { ChannelsComponent } from "./channels.component"; +import { MatAccordion } from "@angular/material/expansion"; + +describe("ChannelsComponent", () => { + let component: ChannelsComponent; + let fixture: ComponentFixture; + + let mockedAsyncApiService = { + getAsyncApi: jest.fn(), + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ChannelsComponent, MatAccordion], + providers: [ + { provide: AsyncApiService, useValue: mockedAsyncApiService }, + ], + }).compileComponents(); + + fixture = TestBed.createComponent(ChannelsComponent as any); + component = fixture.debugElement.componentInstance; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/springwolf-ui/src/app/components/header/header.component.spec.ts b/springwolf-ui/src/app/components/header/header.component.spec.ts new file mode 100644 index 000000000..a75b85ebb --- /dev/null +++ b/springwolf-ui/src/app/components/header/header.component.spec.ts @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { MatToolbarModule } from "@angular/material/toolbar"; +import { HeaderComponent } from "./header.component"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; + +describe("HeaderComponent", () => { + let component: HeaderComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [HeaderComponent], + imports: [MatToolbarModule], + }).compileComponents(); + + fixture = TestBed.createComponent(HeaderComponent as any); + component = fixture.debugElement.componentInstance; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/springwolf-ui/src/app/components/info/info.component.spec.ts b/springwolf-ui/src/app/components/info/info.component.spec.ts index f3f6ac1e5..7a50dd59e 100644 --- a/springwolf-ui/src/app/components/info/info.component.spec.ts +++ b/springwolf-ui/src/app/components/info/info.component.spec.ts @@ -1,10 +1,10 @@ /* SPDX-License-Identifier: Apache-2.0 */ -import {ComponentFixture, TestBed} from "@angular/core/testing"; -import {InfoComponent} from "./info.component"; -import {AsyncApiService} from "../../service/asyncapi/asyncapi.service"; -import {of} from "rxjs/internal/observable/of"; -import {MatChipsModule} from "@angular/material/chips"; -import {MarkdownModule} from "ngx-markdown"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { InfoComponent } from "./info.component"; +import { AsyncApiService } from "../../service/asyncapi/asyncapi.service"; +import { of } from "rxjs/internal/observable/of"; +import { MatChipsModule } from "@angular/material/chips"; +import { MarkdownModule } from "ngx-markdown"; describe("InfoComponent", function () { let component: InfoComponent; @@ -20,14 +20,14 @@ describe("InfoComponent", function () { url: "https://test.com", email: { name: "springwolf", - href: "link" - } + href: "link", + }, }, license: { - name: "Apache License 2.0" + name: "Apache License 2.0", }, asyncApiJson: null, - } + }; beforeEach(() => { mockedAsyncApiService = { @@ -38,7 +38,7 @@ describe("InfoComponent", function () { declarations: [InfoComponent], imports: [MatChipsModule, MarkdownModule.forRoot()], providers: [ - {provide: AsyncApiService, useValue: mockedAsyncApiService}, + { provide: AsyncApiService, useValue: mockedAsyncApiService }, ], }).compileComponents(); @@ -56,9 +56,7 @@ describe("InfoComponent", function () { fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector("h1").textContent).toContain( - "title" - ); + expect(compiled.querySelector("h1").textContent).toContain("title"); expect(compiled.querySelector("h5").textContent).toContain( " API version 1.0.0 - Download AsyncAPI file" ); @@ -73,6 +71,4 @@ describe("InfoComponent", function () { "License: Apache License 2.0 https://test.com springwolf " ); }); - }); - diff --git a/springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts b/springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts new file mode 100644 index 000000000..b1ec7572b --- /dev/null +++ b/springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { ComponentFixture, TestBed } from "@angular/core/testing"; + +import { SchemaComponent } from "./schema.component"; +import { SchemaRangeComponent } from "../range/schema-range.component"; +import { MatChipsModule } from "@angular/material/chips"; +import { MarkdownModule } from "ngx-markdown"; +import { Example } from "../../../models/example.model"; + +describe("SchemaComponent", () => { + let component: SchemaComponent; + let fixture: ComponentFixture; + + let mockedSchemaRangeComponent = jest.mock("../range/schema-range.component"); + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [SchemaComponent, SchemaRangeComponent], + imports: [MatChipsModule, MarkdownModule.forRoot()], + providers: [ + { provide: SchemaRangeComponent, useValue: mockedSchemaRangeComponent }, + ], + }).compileComponents(); + + fixture = TestBed.createComponent(SchemaComponent as any); + component = fixture.debugElement.componentInstance; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); + + it("should render primitive string", async () => { + component.schema = { + title: "String", + type: "string", + example: new Example("string"), + }; + + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector(".type").textContent).toContain("string"); + expect(compiled.querySelector(".example").textContent).toContain( + "example: string" + ); + }); +}); diff --git a/springwolf-ui/src/app/components/schemas/schemas.component.spec.ts b/springwolf-ui/src/app/components/schemas/schemas.component.spec.ts new file mode 100644 index 000000000..c54c42d7e --- /dev/null +++ b/springwolf-ui/src/app/components/schemas/schemas.component.spec.ts @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { SchemasComponent } from "./schemas.component"; +import { AsyncApiService } from "../../service/asyncapi/asyncapi.service"; +import { MatAccordion } from "@angular/material/expansion"; + +describe("SchemasComponent", () => { + let component: SchemasComponent; + let fixture: ComponentFixture; + + let mockedAsyncApiService = { + getAsyncApi: jest.fn(), + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [SchemasComponent, MatAccordion], + providers: [ + { provide: AsyncApiService, useValue: mockedAsyncApiService }, + ], + }).compileComponents(); + + fixture = TestBed.createComponent(SchemasComponent as any); + component = fixture.debugElement.componentInstance; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/springwolf-ui/src/app/components/servers/servers.component.spec.ts b/springwolf-ui/src/app/components/servers/servers.component.spec.ts new file mode 100644 index 000000000..e40a5eb36 --- /dev/null +++ b/springwolf-ui/src/app/components/servers/servers.component.spec.ts @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { ServersComponent } from "./servers.component"; +import { AsyncApiService } from "../../service/asyncapi/asyncapi.service"; + +describe("ServerComponent", () => { + let component: ServersComponent; + let fixture: ComponentFixture; + + let mockedAsyncApiService!: { getAsyncApi: jest.Mock }; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ServersComponent], + providers: [ + { provide: AsyncApiService, useValue: mockedAsyncApiService }, + ], + }).compileComponents(); + + fixture = TestBed.createComponent(ServersComponent as any); + component = fixture.debugElement.componentInstance; + }); + + it("should create the component", () => { + expect(component).toBeTruthy(); + }); +}); From ffcc6e01344b28c55e74ca93c0e2866ccab0d775 Mon Sep 17 00:00:00 2001 From: Nikita Marunko Date: Mon, 8 Apr 2024 22:54:48 +0900 Subject: [PATCH 10/10] test(ui): fix invalid declaration error Material components are mentioned in the wrong section Refs #378 --- .../channels/channel-main/channel-main.component.spec.ts | 7 +++---- .../src/app/components/channels/channels.component.spec.ts | 3 ++- .../app/components/schemas/schema/schema.component.spec.ts | 3 ++- .../src/app/components/schemas/schemas.component.spec.ts | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts index 45ddb6fd0..3c30f6538 100644 --- a/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts +++ b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.spec.ts @@ -21,15 +21,14 @@ describe("ChannelMainComponent", () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [ - ChannelMainComponent, - JsonComponent, + imports: [ MatDivider, MatTabGroup, MatTab, MatTabHeader, + MarkdownModule.forRoot(), ], - imports: [MarkdownModule.forRoot()], + declarations: [ChannelMainComponent, JsonComponent], providers: [ { provide: AsyncApiService, useValue: mockedAsyncApiService }, { provide: PublisherService, useValue: mockedPublisherService }, diff --git a/springwolf-ui/src/app/components/channels/channels.component.spec.ts b/springwolf-ui/src/app/components/channels/channels.component.spec.ts index 0f6e97dd3..66d9093ca 100644 --- a/springwolf-ui/src/app/components/channels/channels.component.spec.ts +++ b/springwolf-ui/src/app/components/channels/channels.component.spec.ts @@ -14,7 +14,8 @@ describe("ChannelsComponent", () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [ChannelsComponent, MatAccordion], + imports: [MatAccordion], + declarations: [ChannelsComponent], providers: [ { provide: AsyncApiService, useValue: mockedAsyncApiService }, ], diff --git a/springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts b/springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts index b1ec7572b..2ebc7315b 100644 --- a/springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts +++ b/springwolf-ui/src/app/components/schemas/schema/schema.component.spec.ts @@ -6,6 +6,7 @@ import { SchemaRangeComponent } from "../range/schema-range.component"; import { MatChipsModule } from "@angular/material/chips"; import { MarkdownModule } from "ngx-markdown"; import { Example } from "../../../models/example.model"; +import { JsonComponent } from "../../json/json.component"; describe("SchemaComponent", () => { let component: SchemaComponent; @@ -15,7 +16,7 @@ describe("SchemaComponent", () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [SchemaComponent, SchemaRangeComponent], + declarations: [SchemaComponent, SchemaRangeComponent, JsonComponent], imports: [MatChipsModule, MarkdownModule.forRoot()], providers: [ { provide: SchemaRangeComponent, useValue: mockedSchemaRangeComponent }, diff --git a/springwolf-ui/src/app/components/schemas/schemas.component.spec.ts b/springwolf-ui/src/app/components/schemas/schemas.component.spec.ts index c54c42d7e..cb792c76c 100644 --- a/springwolf-ui/src/app/components/schemas/schemas.component.spec.ts +++ b/springwolf-ui/src/app/components/schemas/schemas.component.spec.ts @@ -14,7 +14,8 @@ describe("SchemasComponent", () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [SchemasComponent, MatAccordion], + imports: [MatAccordion], + declarations: [SchemasComponent], providers: [ { provide: AsyncApiService, useValue: mockedAsyncApiService }, ],