ocket8888 commented on code in PR #7615:
URL: https://github.com/apache/trafficcontrol/pull/7615#discussion_r1276835270


##########
experimental/traffic-portal/src/app/api/topology.service.ts:
##########
@@ -0,0 +1,185 @@
+/*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import { HttpClient } from "@angular/common/http";
+import { Injectable } from "@angular/core";
+import type {
+       RequestTopology,
+       ResponseTopology,
+       ResponseTopologyNode,
+} from "trafficops-types";
+
+import { APIService } from "./base-api.service";
+
+/**
+ * TopTreeNode is used to represent a topology in a format usable as a material
+ * nested tree data source.
+ */
+export interface TopTreeNode {
+       name: string;
+       cachegroup: string;
+       children: Array<TopTreeNode>;
+       parents: Array<this>;
+}
+
+/**
+ * TopologyService exposes API functionality relating to Topologies.
+ */
+@Injectable()
+export class TopologyService extends APIService {
+
+       constructor(http: HttpClient) {
+               super(http);
+       }
+
+       /**
+        * Gets one or all Topologies from Traffic Ops
+        *
+        * @param name The name of a single Topology to be returned.
+        * @returns An Array of Topologies
+        * whether `name` was   passed.

Review Comment:
   You have a stray tab character in the middle of this sentence.



##########
experimental/traffic-portal/src/app/core/topologies/topology-details/topology-details.component.spec.ts:
##########
@@ -0,0 +1,70 @@
+/*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { MatDialogModule } from "@angular/material/dialog";
+import { ActivatedRoute } from "@angular/router";
+import { RouterTestingModule } from "@angular/router/testing";
+import { ReplaySubject } from "rxjs";
+
+import { APITestingModule } from "src/app/api/testing";
+import {
+       NavigationService
+} from "src/app/shared/navigation/navigation.service";
+
+import { TopologyDetailsComponent } from "./topology-details.component";
+
+describe("TopologyDetailsComponent", () => {
+       let component: TopologyDetailsComponent;
+       let fixture: ComponentFixture<TopologyDetailsComponent>;
+       let route: ActivatedRoute;
+       let paramMap: jasmine.Spy;
+
+       const navSvc = jasmine.createSpyObj([], {
+               headerHidden: new ReplaySubject<boolean>(),
+               headerTitle: new ReplaySubject<string>(),
+       });
+
+       beforeEach(async () => {
+               TestBed.configureTestingModule({
+                       declarations: [TopologyDetailsComponent],
+                       imports: [APITestingModule, RouterTestingModule, 
MatDialogModule],
+                       providers: [{provide: NavigationService, useValue: 
navSvc}],
+               });
+               route = TestBed.inject(ActivatedRoute);
+               paramMap = spyOn(route.snapshot.paramMap, "get");
+               paramMap.and.returnValue(null);
+               fixture = TestBed.createComponent(TopologyDetailsComponent);
+               component = fixture.componentInstance;
+               fixture.detectChanges();
+               await fixture.whenStable();
+       });
+
+       it("should create", () => {
+               expect(component).toBeTruthy();
+               expect(paramMap).toHaveBeenCalled();
+       });
+
+       it("existing topology", async () => {
+               paramMap.and.returnValue("test");
+
+               fixture = TestBed.createComponent(TopologyDetailsComponent);
+               component = fixture.componentInstance;
+               fixture.detectChanges();
+               await fixture.whenStable();
+               expect(paramMap).toHaveBeenCalled();
+               expect(component.topology).toBeInstanceOf(Object);

Review Comment:
   this works, but for whatever it's worth I'd use 
`expect(thing).toBeDefined();`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to