UNPKG

@nova-ui/dashboards

Version:

Nova Dashboards is a framework designed to provide feature developers with a common solution for presenting data coming from various sources within a single view, as well as a set of predefined widget visualizations that are 100% configuration-driven and

144 lines 6.68 kB
"use strict"; // © 2022 SolarWinds Worldwide, LLC. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. Object.defineProperty(exports, "__esModule", { value: true }); const testing_1 = require("@angular/common/http/testing"); const testing_2 = require("@angular/core/testing"); const bits_1 = require("@nova-ui/bits"); const dashboards_1 = require("@nova-ui/dashboards"); const drilldown_widget_test_component_1 = require("./drilldown-widget-test.component"); describe("Drilldown", () => { let component; let fixture; beforeEach((0, testing_2.waitForAsync)(() => { testing_2.TestBed.configureTestingModule({ imports: [ dashboards_1.NuiDashboardsModule, bits_1.NuiButtonModule, bits_1.NuiDocsModule, bits_1.NuiMessageModule, bits_1.NuiSwitchModule, testing_1.HttpClientTestingModule, ], declarations: [drilldown_widget_test_component_1.DrilldownWidgetTestComponent], }).compileComponents(); })); beforeEach(() => { fixture = testing_2.TestBed.createComponent(drilldown_widget_test_component_1.DrilldownWidgetTestComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it("should create", () => { expect(component).toBeTruthy(); }); describe("general > ", () => { it("should set data", async () => { const listWidget = component.drilldownRegistry.componentMap .listWidget; await fixture.whenStable(); fixture.detectChanges(); expect(listWidget.data).toBeTruthy(); }); it("should drilldown", async () => { const listWidget = component.drilldownRegistry.componentMap .listWidget; const adapter = component.drilldownRegistry.providersMap .listWidget.adapter; await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(0); listWidget.onListItemEvent(listWidget.data[0]); await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(1); }); }); describe("navigation bar > ", () => { beforeEach(() => { fixture.detectChanges(); }); it("should navigate back", async () => { const listWidget = component.drilldownRegistry.componentMap .listWidget; const navigationBar = component.drilldownRegistry .componentMap.navigationBar; const adapter = component.drilldownRegistry.providersMap .listWidget.adapter; await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(0); listWidget.onListItemEvent(listWidget.data[0]); await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(1); navigationBar.onBack(); await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(0); }); it("should navigate home", async () => { const listWidget = component.drilldownRegistry.componentMap .listWidget; const navigationBar = component.drilldownRegistry .componentMap.navigationBar; const adapter = component.drilldownRegistry.providersMap .listWidget.adapter; await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(0); listWidget.onListItemEvent(listWidget.data[0]); await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(1); navigationBar.onHome(); await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(0); }); it("should be hidden on home page", async () => { const navigationBar = component.drilldownRegistry .componentMap.navigationBar; const adapter = component.drilldownRegistry.providersMap .listWidget.adapter; await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(0); expect(navigationBar.navBarConfig.isRoot).toBe(true); expect(fixture.nativeElement.querySelector("nui-navigation-bar .list-nav-bar")).toBeFalsy(); }); it("should be visible after drilldown", async () => { const listWidget = component.drilldownRegistry.componentMap .listWidget; const navigationBar = component.drilldownRegistry .componentMap.navigationBar; const adapter = component.drilldownRegistry.providersMap .listWidget.adapter; await fixture.whenStable(); fixture.detectChanges(); listWidget.onListItemEvent(listWidget.data[0]); await fixture.whenStable(); fixture.detectChanges(); expect(adapter.drillstate.length).toBe(1); expect(navigationBar.navBarConfig.isRoot).toBe(false); expect(fixture.nativeElement.querySelector("nui-navigation-bar .list-nav-bar")).toBeTruthy(); }); }); }); //# sourceMappingURL=drilldown-widget-test.component.spec.js.map