From 4c6f6a443cb2e6effa995e77d56689c1c2dab4ad Mon Sep 17 00:00:00 2001 From: jegadeeshbabu3 Date: Fri, 28 Feb 2020 17:42:20 +0530 Subject: [PATCH] Fixed the test cases,added sonar config Fixed test cases and added sonar config details Issue-ID: PORTAL-837 Change-Id: Ie4aa104871cfbbd6c6e36500f5ef2e250bafb575 Signed-off-by: jz385p --- .../components/footer/footer.component.spec.ts | 5 +- .../global-search/global-search.component.spec.ts | 5 +- .../header-menu/header-menu.component.spec.ts | 5 +- .../components/header/header.component.spec.ts | 18 +- .../search-users/search-users.component.spec.ts | 6 +- .../components/sidebar/sidebar.component.spec.ts | 6 +- .../components/tabbar/tabbar.component.spec.ts | 19 +- .../components/userbar/userbar.component.spec.ts | 4 +- .../src/app/layout/layout.component.spec.ts | 8 +- .../confirmation-modal.component.spec.ts | 4 +- .../information-modal.component.spec.ts | 4 +- .../account-add-details.component.spec.ts | 10 +- .../account-onboarding.component.spec.ts | 6 +- .../src/app/pages/admins/admins.component.spec.ts | 6 +- .../admins/new-admin/new-admin.component.spec.ts | 14 +- .../application-catalog.component.spec.ts | 9 +- .../catalog-modal/catalog-modal.component.spec.ts | 4 +- .../contact-us-manage.component.spec.ts | 12 +- .../pages/contact-us/contact-us.component.spec.ts | 5 +- ...dashboard-application-catalog.component.spec.ts | 9 +- .../dashboard-widget-catalog.component.spec.ts | 14 +- .../pages/dashboard/dashboard.component.spec.ts | 11 +- .../functional-menu-dialog.component.spec.ts | 11 +- .../functional-menu.component.spec.ts | 4 +- .../functional-menu/functional-menu.component.ts | 71 ++++---- .../pages/get-access/get-access.component.spec.ts | 6 +- .../microservice-add-details.component.spec.ts | 12 +- .../microservice-onboarding.component.spec.ts | 6 +- .../notification-history.component.spec.ts | 6 +- .../new-portal-admin.component.spec.ts | 14 +- .../portal-admins/portal-admins.component.spec.ts | 6 +- .../pages/role/add-role/add-role.component.spec.ts | 8 +- .../bulk-upload-role.component.spec.ts | 47 ++++- .../role-function-modal.component.spec.ts | 8 +- .../role-functions.component.spec.ts | 7 +- .../src/app/pages/role/role.component.spec.ts | 71 +++++++- .../pages/scheduler/scheduler.component.spec.ts | 199 ++++++++++++++++++++- .../new-notification-modal.component.spec.ts | 55 +++++- .../user-notification-admin.component.spec.ts | 7 +- .../users/bulk-user/bulk-user.component.spec.ts | 11 +- .../src/app/pages/users/users.component.spec.ts | 66 ++++++- .../web-analytics-details-dialog.component.spec.ts | 11 +- .../web-analytics/web-analytics.component.spec.ts | 8 +- .../widget-catalog.component.spec.ts | 15 +- .../widget-details-dialog.component.spec.ts | 12 +- .../widget-onboarding.component.spec.ts | 7 +- .../app/pages/widgets/widgets.component.spec.ts | 5 +- .../app/shared/pipes/elipsis/elipsis.pipe.spec.ts | 8 +- .../list-widget/list-widget.component.spec.ts | 8 +- .../src/app/shared/plugin/plugin.component.spec.ts | 8 +- .../src/app/shared/plugin/plugin.component.ts | 3 +- .../shared/services/admins/admins.service.spec.ts | 36 +++- .../application-catalog.service.spec.ts | 3 +- .../applications/applications.service.spec.ts | 3 +- .../basic-auth-account.service.spec.ts | 3 +- .../services/contact-us/contact-us.service.spec.ts | 24 ++- .../external-request-access.service.spec.ts | 3 +- .../functional-menu.service.spec.ts | 6 +- .../services/get-access/get-access.service.spec.ts | 3 +- .../global-search/global-search.service.spec.ts | 3 +- .../services/manifest/manifest.service.spec.ts | 3 +- .../shared/services/menus/menus.service.spec.ts | 3 +- .../microservice/microservice.service.spec.ts | 3 +- .../notification/notification.service.spec.ts | 3 +- .../portal-admins/portal-admin.service.spec.ts | 3 +- .../app/shared/services/role/role.service.spec.ts | 3 +- .../services/scheduler/scheduler.service.spec.ts | 3 +- .../services/sidebar/sidebar.service.spec.ts | 3 +- .../services/tab/add-tab-function.service.spec.ts | 10 +- .../user-profile/user-profile.service.spec.ts | 22 ++- .../services/userbar/userbar.service.spec.ts | 3 +- .../shared/services/users/users.service.spec.ts | 3 +- .../shared/services/utils/utils.service.spec.ts | 3 +- .../webAnalytics/web-analytics.service.spec.ts | 3 +- .../widget-catalog/widget-catalog.service.spec.ts | 3 +- .../widget-onboarding.service.spec.ts | 3 +- portal-FE-os/package.json | 6 +- portal-FE-os/pom.xml | 21 +++ portal-FE-os/src/app/app.component.spec.ts | 15 +- .../application-details-dialog.component.spec.ts | 73 +++++++- .../application-details-dialog.component.ts | 13 +- .../application-onboarding.component.spec.ts | 6 +- portal-FE-os/src/app/pages/pages.component.spec.ts | 6 +- .../new-user-modal.component.spec.ts | 74 +++++++- .../user-details-form.component.spec.ts | 9 +- .../src/testing/router-link-directive-stub.ts | 14 ++ 86 files changed, 1137 insertions(+), 142 deletions(-) create mode 100644 portal-FE-os/src/testing/router-link-directive-stub.ts diff --git a/portal-FE-common/src/app/layout/components/footer/footer.component.spec.ts b/portal-FE-common/src/app/layout/components/footer/footer.component.spec.ts index b8340222..6e80fce5 100644 --- a/portal-FE-common/src/app/layout/components/footer/footer.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/footer/footer.component.spec.ts @@ -36,6 +36,8 @@ * */ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {HttpClientTestingModule} from '@angular/common/http/testing'; + import { FooterComponent } from './footer.component'; @@ -45,7 +47,8 @@ describe('FooterComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ FooterComponent ] + declarations: [ FooterComponent], + imports: [HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/layout/components/global-search/global-search.component.spec.ts b/portal-FE-common/src/app/layout/components/global-search/global-search.component.spec.ts index c3771377..01879dd1 100644 --- a/portal-FE-common/src/app/layout/components/global-search/global-search.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/global-search/global-search.component.spec.ts @@ -38,6 +38,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { GlobalSearchComponent } from './global-search.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; describe('GlobalSearchComponent', () => { let component: GlobalSearchComponent; @@ -45,7 +47,8 @@ describe('GlobalSearchComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ GlobalSearchComponent ] + declarations: [ GlobalSearchComponent ], + imports: [HttpClientTestingModule, RouterTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/layout/components/header-menu/header-menu.component.spec.ts b/portal-FE-common/src/app/layout/components/header-menu/header-menu.component.spec.ts index 889f499a..bd44038c 100644 --- a/portal-FE-common/src/app/layout/components/header-menu/header-menu.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/header-menu/header-menu.component.spec.ts @@ -38,6 +38,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HeaderMenuComponent } from './header-menu.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; describe('HeaderMenuComponent', () => { let component: HeaderMenuComponent; @@ -45,7 +47,8 @@ describe('HeaderMenuComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ HeaderMenuComponent ] + declarations: [ HeaderMenuComponent ], + imports: [HttpClientTestingModule, RouterTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/layout/components/header/header.component.spec.ts b/portal-FE-common/src/app/layout/components/header/header.component.spec.ts index 1bcd2ffb..fe571914 100644 --- a/portal-FE-common/src/app/layout/components/header/header.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/header/header.component.spec.ts @@ -39,14 +39,22 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HeaderComponent } from './header.component'; +import { Component } from '@angular/core'; +import { RouterLinkDirectiveStub } from 'src/testing/router-link-directive-stub'; +import { RouterTestingModule } from '@angular/router/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { CookieService } from 'ngx-cookie-service'; describe('HeaderComponent', () => { let component: HeaderComponent; let fixture: ComponentFixture; + let cookieService: CookieService; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ HeaderComponent ] + declarations: [ HeaderComponent,AppHeaderMenuStubComponent,AppGlobalSearchStubComponent,RouterLinkDirectiveStub ], + imports: [RouterTestingModule,HttpClientTestingModule], + providers: [CookieService] }) .compileComponents(); })); @@ -54,6 +62,7 @@ describe('HeaderComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(HeaderComponent); component = fixture.componentInstance; + cookieService = TestBed.get(CookieService); fixture.detectChanges(); }); @@ -61,3 +70,10 @@ describe('HeaderComponent', () => { expect(component).toBeTruthy(); }); }); + +@Component({selector: 'app-header-menu', template: ''}) +class AppHeaderMenuStubComponent {} + +@Component({selector: 'app-global-search', template: ''}) +class AppGlobalSearchStubComponent {} + diff --git a/portal-FE-common/src/app/layout/components/search-users/search-users.component.spec.ts b/portal-FE-common/src/app/layout/components/search-users/search-users.component.spec.ts index 66a966cf..9db3e395 100644 --- a/portal-FE-common/src/app/layout/components/search-users/search-users.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/search-users/search-users.component.spec.ts @@ -39,6 +39,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SearchUsersComponent } from './search-users.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { FormsModule } from '@angular/forms'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('SearchUsersComponent', () => { let component: SearchUsersComponent; @@ -46,7 +49,8 @@ describe('SearchUsersComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ SearchUsersComponent ] + declarations: [ SearchUsersComponent ], + imports: [FormsModule,NgMaterialModule,HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.spec.ts b/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.spec.ts index 92caeb42..a9e39a07 100644 --- a/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/sidebar/sidebar.component.spec.ts @@ -38,6 +38,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SidebarComponent } from './sidebar.component'; +import { RouterLinkDirectiveStub } from 'src/testing/router-link-directive-stub'; +import { RouterTestingModule } from '@angular/router/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('SidebarComponent', () => { let component: SidebarComponent; @@ -45,7 +48,8 @@ describe('SidebarComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ SidebarComponent ] + declarations: [ SidebarComponent, RouterLinkDirectiveStub ], + imports: [RouterTestingModule,HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts index 94866e4e..76aaa3e7 100644 --- a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts @@ -39,6 +39,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { TabbarComponent } from './tabbar.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { Component } from '@angular/core'; +import { ElipsisPipe } from 'src/app/shared/pipes/elipsis/elipsis.pipe'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('TabbarComponent', () => { let component: TabbarComponent; @@ -46,7 +50,8 @@ describe('TabbarComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ TabbarComponent ] + declarations: [ TabbarComponent, AppSideBarStubComponent, AppUserBarStubComponent,RouterOutletStubComponent,AppFooterBarStubComponent,ElipsisPipe], + imports: [NgMaterialModule,BrowserAnimationsModule] }) .compileComponents(); })); @@ -61,3 +66,15 @@ describe('TabbarComponent', () => { expect(component).toBeTruthy(); }); }); + +@Component({selector: 'app-sidebar', template: ''}) +class AppSideBarStubComponent {} + +@Component({selector: 'router-outlet', template: ''}) +class RouterOutletStubComponent { } + +@Component({selector: 'app-userbar', template: ''}) +class AppUserBarStubComponent {} + +@Component({selector: 'app-footer', template: ''}) +class AppFooterBarStubComponent {} diff --git a/portal-FE-common/src/app/layout/components/userbar/userbar.component.spec.ts b/portal-FE-common/src/app/layout/components/userbar/userbar.component.spec.ts index 62b9c543..7aeb829d 100644 --- a/portal-FE-common/src/app/layout/components/userbar/userbar.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/userbar/userbar.component.spec.ts @@ -39,6 +39,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UserbarComponent } from './userbar.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('UserbarComponent', () => { let component: UserbarComponent; @@ -46,7 +47,8 @@ describe('UserbarComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ UserbarComponent ] + declarations: [ UserbarComponent ], + imports: [HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/layout/layout.component.spec.ts b/portal-FE-common/src/app/layout/layout.component.spec.ts index 5184fe43..3074c297 100644 --- a/portal-FE-common/src/app/layout/layout.component.spec.ts +++ b/portal-FE-common/src/app/layout/layout.component.spec.ts @@ -38,6 +38,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { LayoutComponent } from './layout.component'; +import { Component } from '@angular/core'; describe('LayoutComponent', () => { let component: LayoutComponent; @@ -45,7 +46,7 @@ describe('LayoutComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ LayoutComponent ] + declarations: [ LayoutComponent,AppheaderStubComponent,AppTabBarStubComponent ] }) .compileComponents(); })); @@ -60,3 +61,8 @@ describe('LayoutComponent', () => { expect(component).toBeTruthy(); }); }); +@Component({selector: 'app-header', template: ''}) +class AppheaderStubComponent {} + +@Component({selector: 'app-tabbar', template: ''}) +class AppTabBarStubComponent { } \ No newline at end of file diff --git a/portal-FE-common/src/app/modals/confirmation-modal/confirmation-modal.component.spec.ts b/portal-FE-common/src/app/modals/confirmation-modal/confirmation-modal.component.spec.ts index bc3516e8..de3b5345 100644 --- a/portal-FE-common/src/app/modals/confirmation-modal/confirmation-modal.component.spec.ts +++ b/portal-FE-common/src/app/modals/confirmation-modal/confirmation-modal.component.spec.ts @@ -38,6 +38,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfirmationModalComponent } from './confirmation-modal.component'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('ConfirmationModalComponent', () => { let component: ConfirmationModalComponent; @@ -45,7 +46,8 @@ describe('ConfirmationModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ConfirmationModalComponent ] + declarations: [ ConfirmationModalComponent ], + providers: [NgbActiveModal] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/modals/information-modal/information-modal.component.spec.ts b/portal-FE-common/src/app/modals/information-modal/information-modal.component.spec.ts index fa3596fe..9e9a80b0 100644 --- a/portal-FE-common/src/app/modals/information-modal/information-modal.component.spec.ts +++ b/portal-FE-common/src/app/modals/information-modal/information-modal.component.spec.ts @@ -38,6 +38,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { InformationModalComponent } from './information-modal.component'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('InformationModalComponent', () => { let component: InformationModalComponent; @@ -45,7 +46,8 @@ describe('InformationModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ InformationModalComponent ] + declarations: [ InformationModalComponent ], + providers: [NgbActiveModal] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/account-onboarding/account-add-details/account-add-details.component.spec.ts b/portal-FE-common/src/app/pages/account-onboarding/account-add-details/account-add-details.component.spec.ts index fd568194..539055d0 100644 --- a/portal-FE-common/src/app/pages/account-onboarding/account-add-details/account-add-details.component.spec.ts +++ b/portal-FE-common/src/app/pages/account-onboarding/account-add-details/account-add-details.component.spec.ts @@ -38,14 +38,21 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AccountAddDetailsComponent } from './account-add-details.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { FormsModule } from '@angular/forms'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('AccountAddDetailsComponent', () => { let component: AccountAddDetailsComponent; let fixture: ComponentFixture; + const accountOnboarding: any = {"applicationName":"Portal-name"} beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ AccountAddDetailsComponent ] + declarations: [ AccountAddDetailsComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule], + providers: [NgbActiveModal] }) .compileComponents(); })); @@ -53,6 +60,7 @@ describe('AccountAddDetailsComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(AccountAddDetailsComponent); component = fixture.componentInstance; + component.accountOnboarding = accountOnboarding; fixture.detectChanges(); }); diff --git a/portal-FE-common/src/app/pages/account-onboarding/account-onboarding.component.spec.ts b/portal-FE-common/src/app/pages/account-onboarding/account-onboarding.component.spec.ts index 8e6e79ea..f567ebe6 100644 --- a/portal-FE-common/src/app/pages/account-onboarding/account-onboarding.component.spec.ts +++ b/portal-FE-common/src/app/pages/account-onboarding/account-onboarding.component.spec.ts @@ -39,6 +39,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AccountOnboardingComponent } from './account-onboarding.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('AccountOnboardingComponent', () => { let component: AccountOnboardingComponent; @@ -46,7 +49,8 @@ describe('AccountOnboardingComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ AccountOnboardingComponent ] + declarations: [ AccountOnboardingComponent ], + imports: [NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/admins/admins.component.spec.ts b/portal-FE-common/src/app/pages/admins/admins.component.spec.ts index 563f80ff..c983cb98 100644 --- a/portal-FE-common/src/app/pages/admins/admins.component.spec.ts +++ b/portal-FE-common/src/app/pages/admins/admins.component.spec.ts @@ -38,6 +38,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AdminsComponent } from './admins.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('AdminsComponent', () => { let component: AdminsComponent; @@ -45,7 +48,8 @@ describe('AdminsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ AdminsComponent ] + declarations: [ AdminsComponent ], + imports: [NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.spec.ts b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.spec.ts index 4040b0d3..df1948ee 100644 --- a/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.spec.ts +++ b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.spec.ts @@ -38,6 +38,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NewAdminComponent } from './new-admin.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { Component, Input } from '@angular/core'; +import { RouterTestingModule } from '@angular/router/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('NewAdminComponent', () => { let component: NewAdminComponent; @@ -45,7 +50,9 @@ describe('NewAdminComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ NewAdminComponent ] + declarations: [ NewAdminComponent,AppSearchUsersStubComponent ], + imports:[NgMaterialModule,RouterTestingModule,HttpClientTestingModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -60,3 +67,8 @@ describe('NewAdminComponent', () => { expect(component).toBeTruthy(); }); }); +@Component({selector: 'app-search-users', template: ''}) +class AppSearchUsersStubComponent { + @Input()searchTitle:any; + @Input()placeHolder:any; + } diff --git a/portal-FE-common/src/app/pages/application-catalog/application-catalog.component.spec.ts b/portal-FE-common/src/app/pages/application-catalog/application-catalog.component.spec.ts index 1967d254..ea2cfdd0 100644 --- a/portal-FE-common/src/app/pages/application-catalog/application-catalog.component.spec.ts +++ b/portal-FE-common/src/app/pages/application-catalog/application-catalog.component.spec.ts @@ -38,6 +38,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ApplicationCatalogComponent } from './application-catalog.component'; +import { RouterLinkDirectiveStub } from 'src/testing/router-link-directive-stub'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { GridsterModule } from 'angular-gridster2'; +import { ElipsisPipe } from 'src/app/shared/pipes/elipsis/elipsis.pipe'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ApplicationCatalogComponent', () => { let component: ApplicationCatalogComponent; @@ -45,7 +51,8 @@ describe('ApplicationCatalogComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ApplicationCatalogComponent ] + declarations: [ ApplicationCatalogComponent,RouterLinkDirectiveStub,ElipsisPipe], + imports: [FormsModule,NgMaterialModule,GridsterModule,HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/catalog-modal/catalog-modal.component.spec.ts b/portal-FE-common/src/app/pages/catalog-modal/catalog-modal.component.spec.ts index b37696f3..064ec104 100644 --- a/portal-FE-common/src/app/pages/catalog-modal/catalog-modal.component.spec.ts +++ b/portal-FE-common/src/app/pages/catalog-modal/catalog-modal.component.spec.ts @@ -38,6 +38,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CatalogModalComponent } from './catalog-modal.component'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('CatalogModalComponent', () => { let component: CatalogModalComponent; @@ -45,7 +46,8 @@ describe('CatalogModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ CatalogModalComponent ] + declarations: [ CatalogModalComponent ], + providers: [NgbActiveModal] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/contact-us/contact-us-manage/contact-us-manage.component.spec.ts b/portal-FE-common/src/app/pages/contact-us/contact-us-manage/contact-us-manage.component.spec.ts index 06b6995a..21224c0a 100644 --- a/portal-FE-common/src/app/pages/contact-us/contact-us-manage/contact-us-manage.component.spec.ts +++ b/portal-FE-common/src/app/pages/contact-us/contact-us-manage/contact-us-manage.component.spec.ts @@ -39,6 +39,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ContactUsManageComponent } from './contact-us-manage.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { Component } from '@angular/core'; describe('ContactUsManageComponent', () => { let component: ContactUsManageComponent; @@ -46,7 +52,9 @@ describe('ContactUsManageComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ContactUsManageComponent ] + declarations: [ ContactUsManageComponent ], + imports: [FormsModule, NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule], + providers: [NgbActiveModal] }) .compileComponents(); })); @@ -61,3 +69,5 @@ describe('ContactUsManageComponent', () => { expect(component).toBeTruthy(); }); }); + + diff --git a/portal-FE-common/src/app/pages/contact-us/contact-us.component.spec.ts b/portal-FE-common/src/app/pages/contact-us/contact-us.component.spec.ts index db77e078..6b38cbd5 100644 --- a/portal-FE-common/src/app/pages/contact-us/contact-us.component.spec.ts +++ b/portal-FE-common/src/app/pages/contact-us/contact-us.component.spec.ts @@ -39,6 +39,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ContactUsComponent } from './contact-us.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ContactUsComponent', () => { let component: ContactUsComponent; @@ -46,7 +48,8 @@ describe('ContactUsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ContactUsComponent ] + declarations: [ ContactUsComponent ], + imports: [NgMaterialModule,HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.spec.ts b/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.spec.ts index 48c91804..42f130af 100644 --- a/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.spec.ts +++ b/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.spec.ts @@ -38,6 +38,12 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DashboardApplicationCatalogComponent } from './dashboard-application-catalog.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { FormsModule } from '@angular/forms'; +import { GridsterModule } from 'angular-gridster2'; +import { ElipsisPipe } from 'src/app/shared/pipes/elipsis/elipsis.pipe'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('DashboardApplicationCatalogComponent', () => { let component: DashboardApplicationCatalogComponent; @@ -45,7 +51,8 @@ describe('DashboardApplicationCatalogComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ DashboardApplicationCatalogComponent ] + declarations: [ DashboardApplicationCatalogComponent,ElipsisPipe ], + imports: [NgMaterialModule,FormsModule,GridsterModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/dashboard-widget-catalog/dashboard-widget-catalog.component.spec.ts b/portal-FE-common/src/app/pages/dashboard-widget-catalog/dashboard-widget-catalog.component.spec.ts index 7ae5f770..768895a7 100644 --- a/portal-FE-common/src/app/pages/dashboard-widget-catalog/dashboard-widget-catalog.component.spec.ts +++ b/portal-FE-common/src/app/pages/dashboard-widget-catalog/dashboard-widget-catalog.component.spec.ts @@ -38,14 +38,21 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DashboardWidgetCatalogComponent } from './dashboard-widget-catalog.component'; +import { Component, Input } from '@angular/core'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { GridsterModule } from 'angular-gridster2'; +import { ElipsisPipe } from 'src/app/shared/pipes/elipsis/elipsis.pipe'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('DashboardWidgetCatalogComponent', () => { let component: DashboardWidgetCatalogComponent; let fixture: ComponentFixture; + beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ DashboardWidgetCatalogComponent ] + declarations: [ DashboardWidgetCatalogComponent,AppDynamicWidgetStubComponent,ElipsisPipe ], + imports:[NgMaterialModule,GridsterModule,HttpClientTestingModule] }) .compileComponents(); })); @@ -60,3 +67,8 @@ describe('DashboardWidgetCatalogComponent', () => { expect(component).toBeTruthy(); }); }); + +@Component({selector: 'app-dynamic-widget', template: ''}) +class AppDynamicWidgetStubComponent { + @Input() widgetType:any; +} \ No newline at end of file diff --git a/portal-FE-common/src/app/pages/dashboard/dashboard.component.spec.ts b/portal-FE-common/src/app/pages/dashboard/dashboard.component.spec.ts index 9c996c37..3c8a7e04 100644 --- a/portal-FE-common/src/app/pages/dashboard/dashboard.component.spec.ts +++ b/portal-FE-common/src/app/pages/dashboard/dashboard.component.spec.ts @@ -1,6 +1,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DashboardComponent } from './dashboard.component'; +import { Component } from '@angular/core'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('DashboardComponent', () => { let component: DashboardComponent; @@ -8,7 +10,8 @@ describe('DashboardComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ DashboardComponent ] + declarations: [ DashboardComponent, AppDashBoardApplicationCatalogComponent,AppDashBoardWidgetCatalogComponent ], + imports:[HttpClientTestingModule] }) .compileComponents(); })); @@ -23,3 +26,9 @@ describe('DashboardComponent', () => { expect(component).toBeTruthy(); }); }); + +@Component({selector: 'app-dashboard-application-catalog', template: ''}) +class AppDashBoardApplicationCatalogComponent {} + +@Component({selector: 'app-dashboard-widget-catalog', template: ''}) +class AppDashBoardWidgetCatalogComponent {} diff --git a/portal-FE-common/src/app/pages/functional-menu/functional-menu-dialog/functional-menu-dialog.component.spec.ts b/portal-FE-common/src/app/pages/functional-menu/functional-menu-dialog/functional-menu-dialog.component.spec.ts index de79b9d8..439a2eeb 100644 --- a/portal-FE-common/src/app/pages/functional-menu/functional-menu-dialog/functional-menu-dialog.component.spec.ts +++ b/portal-FE-common/src/app/pages/functional-menu/functional-menu-dialog/functional-menu-dialog.component.spec.ts @@ -39,14 +39,22 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { FunctionalMenuDialogComponent } from './functional-menu-dialog.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('FunctionalMenuDialogComponent', () => { let component: FunctionalMenuDialogComponent; let fixture: ComponentFixture; + const nodedata: any = {"parentMenuId":"parentMenuTestId","children":{},"name":"TestName","parent":{"name":"TestParentName"}}; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ FunctionalMenuDialogComponent ] + declarations: [ FunctionalMenuDialogComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -54,6 +62,7 @@ describe('FunctionalMenuDialogComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(FunctionalMenuDialogComponent); component = fixture.componentInstance; + component.nodedata = nodedata; fixture.detectChanges(); }); diff --git a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.spec.ts b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.spec.ts index c5c562ed..ef05c229 100644 --- a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.spec.ts +++ b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.spec.ts @@ -1,6 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { FunctionalMenuComponent } from './functional-menu.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('FunctionalMenuComponent', () => { let component: FunctionalMenuComponent; @@ -8,7 +9,8 @@ describe('FunctionalMenuComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ FunctionalMenuComponent ] + declarations: [ FunctionalMenuComponent ], + imports:[HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts index 655b4cb4..d3b5a164 100644 --- a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts +++ b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts @@ -152,41 +152,42 @@ export class FunctionalMenuComponent implements OnInit { */ buildTree(treedataarray,ngbModal: NgbModal , _self){ //console.log("treedataarray>>>>",treedataarray); - $(function() { - $('#jqTree').tree('loadData', treedataarray); - $('#jqTree').tree({ - data: treedataarray, - autoOpen: false, - dragAndDrop: true, - onCreateLi: function(node, $li) { - ////console.log("node >>",node); - } - }).on( - 'tree.contextmenu', - function(event:any) { - // The clicked node is 'event.node' - var node = event.node; - openMenuDetailsModal(node, "view"); - } - ); + // $(function() { + // $('#jqTree').tree('loadData', treedataarray); + // $('#jqTree').tree({ + // data: treedataarray, + // autoOpen: false, + // dragAndDrop: true, + // onCreateLi: function(node, $li) { + // ////console.log("node >>",node); + // } + // }).on( + // 'tree.contextmenu', + // function(event:any) { + // // The clicked node is 'event.node' + // var node = event.node; + // openMenuDetailsModal(node, "view"); + // } + // ); - var openMenuDetailsModal = function(node: any, actionName: string ){ - const modalRef = ngbModal.open(FunctionalMenuDialogComponent, { size: 'lg' }); - modalRef.componentInstance.title = 'Functional Menu ',actionName; - if(node != 'undefined' && node){ - modalRef.componentInstance.nodedata = node; - modalRef.componentInstance.operationName = actionName; - }else{ - modalRef.componentInstance.nodedata = {}; - } - modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => { - //console.log("receivedEntry>>>>",receivedEntry); - ngbModal.dismissAll(); - if(receivedEntry.httpStatusCode===200){ - _self.getFunctionalMenu(); - } - }); - } - }); + // var openMenuDetailsModal = function(node: any, actionName: string ){ + // const modalRef = ngbModal.open(FunctionalMenuDialogComponent, { size: 'lg' }); + // modalRef.componentInstance.title = 'Functional Menu ',actionName; + // if(node != 'undefined' && node){ + // modalRef.componentInstance.nodedata = node; + // modalRef.componentInstance.operationName = actionName; + // }else{ + // modalRef.componentInstance.nodedata = {}; + // } + // modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => { + // //console.log("receivedEntry>>>>",receivedEntry); + // ngbModal.dismissAll(); + // if(receivedEntry.httpStatusCode===200){ + // _self.getFunctionalMenu(); + // } + // }); + // } + // }); + // } } } diff --git a/portal-FE-common/src/app/pages/get-access/get-access.component.spec.ts b/portal-FE-common/src/app/pages/get-access/get-access.component.spec.ts index ae61740d..0594fccd 100644 --- a/portal-FE-common/src/app/pages/get-access/get-access.component.spec.ts +++ b/portal-FE-common/src/app/pages/get-access/get-access.component.spec.ts @@ -1,6 +1,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { GetAccessComponent } from './get-access.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('GetAccessComponent', () => { let component: GetAccessComponent; @@ -8,7 +11,8 @@ describe('GetAccessComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ GetAccessComponent ] + declarations: [ GetAccessComponent ], + imports:[NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts index 5589854c..f2344bda 100644 --- a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-add-details/microservice-add-details.component.spec.ts @@ -38,14 +38,23 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MicroserviceAddDetailsComponent } from './microservice-add-details.component'; +import { ReactiveFormsModule, FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { IMircroservies } from 'src/app/shared/model/microservice-onboarding/microservices'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('MicroserviceAddDetailsComponent', () => { let component: MicroserviceAddDetailsComponent; let fixture: ComponentFixture; + const ms: IMircroservies = {"name":"MicorserviceName"}; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ MicroserviceAddDetailsComponent ] + declarations: [ MicroserviceAddDetailsComponent ], + imports: [ReactiveFormsModule,FormsModule,NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -53,6 +62,7 @@ describe('MicroserviceAddDetailsComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(MicroserviceAddDetailsComponent); component = fixture.componentInstance; + component.ms = ms; fixture.detectChanges(); }); diff --git a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts index 09d30a14..6068590f 100644 --- a/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts +++ b/portal-FE-common/src/app/pages/microservice-onboarding/microservice-onboarding.component.spec.ts @@ -39,6 +39,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MicroserviceOnboardingComponent } from './microservice-onboarding.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('MicroserviceOnboardingComponent', () => { let component: MicroserviceOnboardingComponent; @@ -46,7 +49,8 @@ describe('MicroserviceOnboardingComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ MicroserviceOnboardingComponent ] + declarations: [ MicroserviceOnboardingComponent ], + imports:[NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/notification-history/notification-history.component.spec.ts b/portal-FE-common/src/app/pages/notification-history/notification-history.component.spec.ts index 6896359a..68da263b 100644 --- a/portal-FE-common/src/app/pages/notification-history/notification-history.component.spec.ts +++ b/portal-FE-common/src/app/pages/notification-history/notification-history.component.spec.ts @@ -39,6 +39,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NotificationHistoryComponent } from './notification-history.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('NotificationHistoryComponent', () => { let component: NotificationHistoryComponent; @@ -46,7 +49,8 @@ describe('NotificationHistoryComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ NotificationHistoryComponent ] + declarations: [ NotificationHistoryComponent ], + imports:[NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/portal-admins/new-portal-admin/new-portal-admin.component.spec.ts b/portal-FE-common/src/app/pages/portal-admins/new-portal-admin/new-portal-admin.component.spec.ts index cd85fca1..131d2aff 100644 --- a/portal-FE-common/src/app/pages/portal-admins/new-portal-admin/new-portal-admin.component.spec.ts +++ b/portal-FE-common/src/app/pages/portal-admins/new-portal-admin/new-portal-admin.component.spec.ts @@ -38,6 +38,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NewPortalAdminComponent } from './new-portal-admin.component'; +import { Component, Input } from '@angular/core'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('NewPortalAdminComponent', () => { let component: NewPortalAdminComponent; @@ -45,7 +49,9 @@ describe('NewPortalAdminComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ NewPortalAdminComponent ] + declarations: [ NewPortalAdminComponent,AppSearchUsersStubComponent ], + providers:[NgbActiveModal], + imports:[HttpClientTestingModule] }) .compileComponents(); })); @@ -60,3 +66,9 @@ describe('NewPortalAdminComponent', () => { expect(component).toBeTruthy(); }); }); + +@Component({selector: 'app-search-users', template: ''}) +class AppSearchUsersStubComponent { + @Input() searchTitle:any; + @Input() placeHolder:any; +} diff --git a/portal-FE-common/src/app/pages/portal-admins/portal-admins.component.spec.ts b/portal-FE-common/src/app/pages/portal-admins/portal-admins.component.spec.ts index 0e3c969f..d8cdbc23 100644 --- a/portal-FE-common/src/app/pages/portal-admins/portal-admins.component.spec.ts +++ b/portal-FE-common/src/app/pages/portal-admins/portal-admins.component.spec.ts @@ -38,6 +38,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { PortalAdminsComponent } from './portal-admins.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('PortalAdminsComponent', () => { let component: PortalAdminsComponent; @@ -45,7 +48,8 @@ describe('PortalAdminsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ PortalAdminsComponent ] + declarations: [ PortalAdminsComponent ], + imports:[NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/role/add-role/add-role.component.spec.ts b/portal-FE-common/src/app/pages/role/add-role/add-role.component.spec.ts index 1104010d..1894fa8a 100644 --- a/portal-FE-common/src/app/pages/role/add-role/add-role.component.spec.ts +++ b/portal-FE-common/src/app/pages/role/add-role/add-role.component.spec.ts @@ -38,6 +38,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AddRoleComponent } from './add-role.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AddRoleComponent', () => { let component: AddRoleComponent; @@ -45,7 +49,9 @@ describe('AddRoleComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ AddRoleComponent ] + declarations: [ AddRoleComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule], + providers:[NgbActiveModal] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/role/bulk-upload-role/bulk-upload-role.component.spec.ts b/portal-FE-common/src/app/pages/role/bulk-upload-role/bulk-upload-role.component.spec.ts index d4006a08..db83c1a3 100644 --- a/portal-FE-common/src/app/pages/role/bulk-upload-role/bulk-upload-role.component.spec.ts +++ b/portal-FE-common/src/app/pages/role/bulk-upload-role/bulk-upload-role.component.spec.ts @@ -38,6 +38,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { BulkUploadRoleComponent } from './bulk-upload-role.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('BulkUploadRoleComponent', () => { let component: BulkUploadRoleComponent; @@ -45,7 +49,9 @@ describe('BulkUploadRoleComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ BulkUploadRoleComponent ] + declarations: [ BulkUploadRoleComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -59,4 +65,43 @@ describe('BulkUploadRoleComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('changeUploadTypeInstruction should return stubbed value', () => { + spyOn(component, 'changeUploadTypeInstruction').and.callThrough(); + component.changeUploadTypeInstruction("functions"); + expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("functions"); + component.changeUploadTypeInstruction("roles"); + expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("roles"); + component.changeUploadTypeInstruction("roleFunctions"); + expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("roleFunctions"); + component.changeUploadTypeInstruction("default"); + expect(component.changeUploadTypeInstruction).toHaveBeenCalledWith("default") ; + }); + + it('navigateUploadScreen should return stubbed value', () => { + spyOn(component, 'navigateUploadScreen').and.callThrough(); + component.selectedUploadDropdown.value='functions'; + component.navigateUploadScreen(); + expect(component.navigateUploadScreen).toHaveBeenCalledWith(); + component.selectedUploadDropdown.value='roles'; + component.navigateUploadScreen(); + expect(component.navigateUploadScreen).toHaveBeenCalledWith(); + component.selectedUploadDropdown.value='roleFunctions'; + component.navigateUploadScreen(); + expect(component.navigateUploadScreen).toHaveBeenCalledWith(); + component.selectedUploadDropdown.value='default'; + component.navigateUploadScreen(); + expect(component.navigateUploadScreen).toHaveBeenCalledWith(); + }); + it('navigateSelectTypeUpload should return stubbed value', () => { + spyOn(component, 'navigateSelectTypeUpload').and.callThrough(); + component.navigateSelectTypeUpload(); + expect(component.navigateSelectTypeUpload).toHaveBeenCalledWith(); + }); + + it('getSortOrder should return stubbed value', () => { + spyOn(component, 'getSortOrder').and.callThrough(); + component.getSortOrder(1,true); + expect(component.getSortOrder).toHaveBeenCalledWith(1,true); + }); }); diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts index 2c5ef631..1ea73246 100644 --- a/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts +++ b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts @@ -38,6 +38,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RoleFunctionModalComponent } from './role-function-modal.component'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('RoleFunctionModalComponent', () => { let component: RoleFunctionModalComponent; @@ -45,7 +49,9 @@ describe('RoleFunctionModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RoleFunctionModalComponent ] + declarations: [ RoleFunctionModalComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule], + providers:[NgbActiveModal] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts index ccefb8d2..8aa41e06 100644 --- a/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts +++ b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts @@ -38,6 +38,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RoleFunctionsComponent } from './role-functions.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('RoleFunctionsComponent', () => { let component: RoleFunctionsComponent; @@ -45,7 +49,8 @@ describe('RoleFunctionsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RoleFunctionsComponent ] + declarations: [ RoleFunctionsComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule], }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/role/role.component.spec.ts b/portal-FE-common/src/app/pages/role/role.component.spec.ts index 2dc104d8..1ae0caa4 100644 --- a/portal-FE-common/src/app/pages/role/role.component.spec.ts +++ b/portal-FE-common/src/app/pages/role/role.component.spec.ts @@ -38,6 +38,17 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RoleComponent } from './role.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterLinkDirectiveStub } from 'src/testing/router-link-directive-stub'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { BulkUploadRoleComponent } from './bulk-upload-role/bulk-upload-role.component'; +import { AddRoleComponent } from './add-role/add-role.component'; describe('RoleComponent', () => { let component: RoleComponent; @@ -45,8 +56,9 @@ describe('RoleComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RoleComponent ] - }) + declarations: [ RoleComponent,RouterLinkDirectiveStub,InformationModalComponent,ConfirmationModalComponent,BulkUploadRoleComponent,AddRoleComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule,NgbModule.forRoot()], + }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent,BulkUploadRoleComponent,AddRoleComponent] } }) .compileComponents(); })); @@ -59,4 +71,59 @@ describe('RoleComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('toggleRole should return stubbed value', () => { + spyOn(component, 'toggleRole').and.callThrough(); + let element={"id":1,"active":true}; + component.toggleRole(element); + expect(component.toggleRole).toHaveBeenCalledWith(element); + }); + + it('openBulkUploadRolesAndFunctionsModal should return stubbed value', () => { + spyOn(component, 'openBulkUploadRolesAndFunctionsModal').and.callThrough(); + component.openBulkUploadRolesAndFunctionsModal(); + expect(component.openBulkUploadRolesAndFunctionsModal).toHaveBeenCalledWith(); + }); + it('editRoleModalPopup should return stubbed value', () => { + spyOn(component, 'editRoleModalPopup').and.callThrough(); + let element={"id":1,"active":true}; + component.editRoleModalPopup(element); + expect(component.editRoleModalPopup).toHaveBeenCalledWith(element); + }); + + it('addRoleModalPopup should return stubbed value', () => { + spyOn(component, 'addRoleModalPopup').and.callThrough(); + component.addRoleModalPopup(); + expect(component.addRoleModalPopup).toHaveBeenCalledWith(); + }); + + it('removeRole should return stubbed value', () => { + spyOn(component, 'removeRole').and.callThrough(); + let element={"id":1,"active":true,"name":"Test_global_"}; + component.selectedCentralizedApp = 2; + component.removeRole(element); + expect(component.removeRole).toHaveBeenCalledWith(element); + }); + it('getCentralizedApps should return stubbed value', () => { + spyOn(component, 'getCentralizedApps').and.callThrough(); + component.getCentralizedApps('admin'); + expect(component.getCentralizedApps).toHaveBeenCalledWith('admin'); + }); + it('syncRolesFromExternalAuthSystem should return stubbed value', () => { + spyOn(component, 'syncRolesFromExternalAuthSystem').and.callThrough(); + component.selectedCentralizedApp = 'Test'; + component.syncRolesFromExternalAuthSystem(); + expect(component.syncRolesFromExternalAuthSystem).toHaveBeenCalledWith(); + }); + it('getRolesForSelectedCentralizedApp should return stubbed value', () => { + spyOn(component, 'getRolesForSelectedCentralizedApp').and.callThrough(); + component.getRolesForSelectedCentralizedApp('Test'); + expect(component.getRolesForSelectedCentralizedApp).toHaveBeenCalledWith('Test'); + }); + + + + + + }); diff --git a/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts b/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts index 35f9b50d..02ce3a8a 100644 --- a/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts +++ b/portal-FE-common/src/app/pages/scheduler/scheduler.component.spec.ts @@ -38,25 +38,220 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SchedulerComponent } from './scheduler.component'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; describe('SchedulerComponent', () => { let component: SchedulerComponent; let fixture: ComponentFixture; + const payload: any = {"widgetData":"widgetTestData"}; + const policy = ["test1","test2","test3"]; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ SchedulerComponent ] - }) + declarations: [ SchedulerComponent,InformationModalComponent,ConfirmationModalComponent ], + imports:[FormsModule,NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule,NgbModule.forRoot()], + providers:[NgbActiveModal] + }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent] } }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(SchedulerComponent); component = fixture.componentInstance; + component.payload =payload; + component.policys = policy; + component.schedulerObjConst.WorkflowName = "workFlowName"; + component.schedulerObj.domainData=[{"WorkflowName":"test"}]; + // component.schedulerObj.schedulingInfo.normalDurationInSeconds= 20; + component.vnfObject = { + workflow: null, + vnfNames:'test1' + }; + component.schedulerObj.schedulingInfo = { + normalDurationInSeconds: '', + additionalDurationInSeconds: '', + concurrencyLimit: '', + policyId: '', + vnfDetails: [ + { + groupId: "", + node: [], + changeWindow: [{ + startTime: '', + endTime: '' + }] + }] + }; + + // component.schedulerObj.schedulingInfo.additionalDurationInSeconds= null; + // component.schedulerObj.schedulingInfo.concurrencyLimit=null; + // component.schedulerObj.schedulingInfo['vnfDetails'][0].groupId=null; + // component.schedulerObj.schedulingInfo['vnfDetails'][0].node=null; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('radioSelections should return stubbed value', () => { + spyOn(component, 'radioSelections').and.callThrough(); + component.schedulerForm.checkboxSelection = "true"; + component.radioSelections(); + expect(component.radioSelections).toHaveBeenCalledWith(); + }); + + it('onChangeUpdatePolicyName should return stubbed value', () => { + spyOn(component, 'onChangeUpdatePolicyName').and.callThrough(); + component.onChangeUpdatePolicyName("test1","test1"); + expect(component.onChangeUpdatePolicyName).toHaveBeenCalledWith("test1","test1"); + }); + + it('onChangeUpdateTimeUnit should return stubbed value', () => { + spyOn(component, 'onChangeUpdateTimeUnit').and.callThrough(); + component.onChangeUpdateTimeUnit("HOURS","HOURS"); + expect(component.onChangeUpdateTimeUnit).toHaveBeenCalledWith("HOURS","HOURS"); + }); + it('isDateValid should return stubbed value', () => { + spyOn(component, 'isDateValid').and.callThrough(); + component.isDateValid("10/24/2020"); + expect(component.isDateValid).toHaveBeenCalledWith("10/24/2020"); + }); + it('isStartDateValidFromToday should return stubbed value', () => { + spyOn(component, 'isStartDateValidFromToday').and.callThrough(); + component.isStartDateValidFromToday("10/24/2020"); + expect(component.isStartDateValidFromToday).toHaveBeenCalledWith("10/24/2020"); + component.isStartDateValidFromToday("10/24/2021"); + expect(component.isStartDateValidFromToday).toHaveBeenCalledWith("10/24/2021"); + }); + + it('isToDateGreaterFromDate should return stubbed value', () => { + spyOn(component, 'isToDateGreaterFromDate').and.callThrough(); + component.isToDateGreaterFromDate('10/24/2020','10/24/2021'); + expect(component.isToDateGreaterFromDate).toHaveBeenCalledWith('10/24/2020','10/24/2021'); + component.isToDateGreaterFromDate('10/24/2021','10/24/2020'); + expect(component.isToDateGreaterFromDate).toHaveBeenCalledWith('10/24/2021','10/24/2020'); + }); + + it('submit should return stubbed value', () => { + spyOn(component, 'submit').and.callThrough(); + component.timeSlots = [{"startTime":"10/24/2021"}]; + component.submit(); + expect(component.submit).toHaveBeenCalledWith(); + }); + + it('reject should return stubbed value', () => { + spyOn(component, 'reject').and.callThrough(); + component.timeSlots = [{"startTime":"10/24/2021"}]; + component.reject(); + expect(component.reject).toHaveBeenCalledWith(); + }); + + // it('sendSchedulerReq should return stubbed value', () => { + // spyOn(component, 'sendSchedulerReq').and.callThrough(); + // component.timeSlots = [{"startTime":"10/24/2021"}]; + // component.sendSchedulerReq(); + // expect(component.sendSchedulerReq).toHaveBeenCalledWith(); + // }); + it('seviceCallToGetTimeSlots should return stubbed value', () => { + spyOn(component, 'seviceCallToGetTimeSlots').and.callThrough(); + component.seviceCallToGetTimeSlots(); + expect(component.seviceCallToGetTimeSlots).toHaveBeenCalledWith(); + }); + + it('getPolicy should return stubbed value', () => { + spyOn(component, 'getPolicy').and.callThrough(); + component.getPolicy(); + expect(component.getPolicy).toHaveBeenCalledWith(); + }); + + it('parseErrorMsg should return stubbed value', () => { + const response ={"entity":{"requestError":{"text":"EmptyTest"}}}; + spyOn(component, 'parseErrorMsg').and.callThrough(); + component.parseErrorMsg(response,"TestMethod"); + expect(component.parseErrorMsg).toHaveBeenCalledWith(response,"TestMethod"); + }); + + it('extractChangeManagementCallbackDataStr should return stubbed value', () => { + let response ={"workflow":"Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + spyOn(component, 'extractChangeManagementCallbackDataStr').and.callThrough(); + + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + response ={"workflow":"Replace","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + response ={"workflow":"VNF In Place Software Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + response ={"workflow":"VNF Config Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + + response ={"workflow":"VNF In Place Software Update","vnfNames":[ + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}, + {"availableVersions":[{"requestInfo":{"source":"URL","suppressRollback":"suppressRollback","requestorId":"requestorId"},"requestParameters":{"usePreload":2}}]}]}; + component.extractChangeManagementCallbackDataStr(response); + expect(component.extractChangeManagementCallbackDataStr).toHaveBeenCalledWith(response); + }); + it('formValidation should return stubbed value', () => { + spyOn(component, 'formValidation').and.callThrough(); + component.formValidation(); + expect(component.formValidation).toHaveBeenCalledWith(); + }); + + it('convertToSecs should return stubbed value', () => { + spyOn(component, 'convertToSecs').and.callThrough(); + component.convertToSecs(200); + expect(component.convertToSecs).toHaveBeenCalledWith(200); + }); + + it('stopPoll should return stubbed value', () => { + spyOn(component, 'stopPoll').and.callThrough(); + component.stopPoll(); + expect(component.stopPoll).toHaveBeenCalledWith(); + }); + + it('getVnfData should return stubbed value', () => { + spyOn(component, 'getVnfData').and.callThrough(); + component.getVnfData([{"name":"testName"}]); + expect(component.getVnfData).toHaveBeenCalledWith([{"name":"testName"}]); + }); + + it('openConfirmationModal should return stubbed value', () => { + spyOn(component, 'openConfirmationModal').and.callThrough(); + component.openConfirmationModal("Test1","Test1"); + expect(component.openConfirmationModal).toHaveBeenCalledWith("Test1","Test1"); + }); + + it('openInformationModal should return stubbed value', () => { + spyOn(component, 'openInformationModal').and.callThrough(); + component.openInformationModal("Test1","Test1"); + expect(component.openInformationModal).toHaveBeenCalledWith("Test1","Test1"); + }); + + + + + + + + + + }); diff --git a/portal-FE-common/src/app/pages/user-notification-admin/new-notification-modal/new-notification-modal.component.spec.ts b/portal-FE-common/src/app/pages/user-notification-admin/new-notification-modal/new-notification-modal.component.spec.ts index 142a0ba0..cc32f248 100644 --- a/portal-FE-common/src/app/pages/user-notification-admin/new-notification-modal/new-notification-modal.component.spec.ts +++ b/portal-FE-common/src/app/pages/user-notification-admin/new-notification-modal/new-notification-modal.component.spec.ts @@ -39,15 +39,28 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NewNotificationModalComponent } from './new-notification-modal.component'; +import { FormsModule } from '@angular/forms'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; describe('NewNotificationModalComponent', () => { let component: NewNotificationModalComponent; + let component1: NewNotificationModalComponent; let fixture: ComponentFixture; + let fixture1: ComponentFixture; + const selectedNotification ={"msgSource":"TestSource","priority":1,"startTime":"10/11/2020","endTime":"10/11/2021"} beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ NewNotificationModalComponent ] - }) + declarations: [ NewNotificationModalComponent ,InformationModalComponent,ConfirmationModalComponent], + imports:[FormsModule,HttpClientTestingModule,NgMaterialModule,BrowserAnimationsModule,NgbModule.forRoot()], + providers:[NgbActiveModal] + }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent] } }) .compileComponents(); })); @@ -55,9 +68,47 @@ describe('NewNotificationModalComponent', () => { fixture = TestBed.createComponent(NewNotificationModalComponent); component = fixture.componentInstance; fixture.detectChanges(); + + + fixture1 = TestBed.createComponent(NewNotificationModalComponent); + component1 = fixture1.componentInstance; + component1.selectedNotification = selectedNotification; + fixture1.detectChanges(); + + }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('addUserNotification should return stubbed value', () => { + spyOn(component1, 'addUserNotification').and.callThrough(); + component1.addUserNotification(); + expect(component1.addUserNotification).toHaveBeenCalledWith(); + }); + + it('settingTreeParam should return stubbed value', () => { + spyOn(component1, 'settingTreeParam').and.callThrough(); + component1.settingTreeParam(); + expect(component1.settingTreeParam).toHaveBeenCalledWith(); + }); + + it('checkTreeSelect should return stubbed value', () => { + spyOn(component1, 'checkTreeSelect').and.callThrough(); + component1.checkTreeSelect(); + expect(component1.checkTreeSelect).toHaveBeenCalledWith(); + }); + + it('openConfirmationModal should return stubbed value', () => { + spyOn(component1, 'openConfirmationModal').and.callThrough(); + component1.openConfirmationModal('Title','Message'); + expect(component1.openConfirmationModal).toHaveBeenCalledWith('Title','Message'); + }); + + it('openInformationModal should return stubbed value', () => { + spyOn(component1, 'openInformationModal').and.callThrough(); + component1.openInformationModal('Title','Message'); + expect(component1.openInformationModal).toHaveBeenCalledWith('Title','Message'); + }); }); diff --git a/portal-FE-common/src/app/pages/user-notification-admin/user-notification-admin.component.spec.ts b/portal-FE-common/src/app/pages/user-notification-admin/user-notification-admin.component.spec.ts index 82b4e129..0c82bb6f 100644 --- a/portal-FE-common/src/app/pages/user-notification-admin/user-notification-admin.component.spec.ts +++ b/portal-FE-common/src/app/pages/user-notification-admin/user-notification-admin.component.spec.ts @@ -39,6 +39,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UserNotificationAdminComponent } from './user-notification-admin.component'; +import { FormsModule } from '@angular/forms'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('UserNotificationAdminComponent', () => { let component: UserNotificationAdminComponent; @@ -46,7 +50,8 @@ describe('UserNotificationAdminComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ UserNotificationAdminComponent ] + declarations: [ UserNotificationAdminComponent ], + imports:[FormsModule,HttpClientTestingModule,NgMaterialModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/users/bulk-user/bulk-user.component.spec.ts b/portal-FE-common/src/app/pages/users/bulk-user/bulk-user.component.spec.ts index 05b04a96..b16dbc7a 100644 --- a/portal-FE-common/src/app/pages/users/bulk-user/bulk-user.component.spec.ts +++ b/portal-FE-common/src/app/pages/users/bulk-user/bulk-user.component.spec.ts @@ -38,14 +38,22 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { BulkUserComponent } from './bulk-user.component'; +import { FormsModule } from '@angular/forms'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('BulkUserComponent', () => { let component: BulkUserComponent; let fixture: ComponentFixture; + const adminsAppsData:any =[{"titel":"TestDummyTitle"}]; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ BulkUserComponent ] + declarations: [ BulkUserComponent ], + imports:[FormsModule,HttpClientTestingModule,NgMaterialModule,BrowserAnimationsModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -53,6 +61,7 @@ describe('BulkUserComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(BulkUserComponent); component = fixture.componentInstance; + component.adminsAppsData = adminsAppsData; fixture.detectChanges(); }); diff --git a/portal-FE-common/src/app/pages/users/users.component.spec.ts b/portal-FE-common/src/app/pages/users/users.component.spec.ts index 60d024ba..10414842 100644 --- a/portal-FE-common/src/app/pages/users/users.component.spec.ts +++ b/portal-FE-common/src/app/pages/users/users.component.spec.ts @@ -38,6 +38,16 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UsersComponent } from './users.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { NewUserModalComponent } from './new-user-modal/new-user-modal.component'; +import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { BulkUserComponent } from './bulk-user/bulk-user.component'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { Component, Input } from '@angular/core'; describe('UsersComponent', () => { let component: UsersComponent; @@ -45,8 +55,9 @@ describe('UsersComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ UsersComponent ] - }) + declarations: [ UsersComponent, NewUserModalComponent,BulkUserComponent,ConfirmationModalComponent,AppSearchUsersStubComponent,AppUsersdetailsFormStubComponent], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule,NgbModule.forRoot()] + }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [NewUserModalComponent,BulkUserComponent,ConfirmationModalComponent] } }) .compileComponents(); })); @@ -59,4 +70,55 @@ describe('UsersComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('openAddNewUserModal should return stubbed value', () => { + spyOn(component, 'openAddNewUserModal').and.callThrough(); + component.openAddNewUserModal(); + expect(component.openAddNewUserModal).toHaveBeenCalledWith(); + }); + it('openExistingUserModal should return stubbed value', () => { + spyOn(component, 'openExistingUserModal').and.callThrough(); + let user ={"firstName":"FirstTestName","lastName":"LastTestName","orgUserId":""}; + component.openExistingUserModal(user); + expect(component.openExistingUserModal).toHaveBeenCalledWith(user); + }); + + it('openBulkUserUploadModal should return stubbed value', () => { + spyOn(component, 'openBulkUserUploadModal').and.callThrough(); + component.openBulkUserUploadModal(); + expect(component.openBulkUserUploadModal).toHaveBeenCalledWith(); + }); + it('applyDropdownFilter should return stubbed value', () => { + spyOn(component, 'applyDropdownFilter').and.callThrough(); + let _appValue= {"value":"select-application"}; + component.applyDropdownFilter(_appValue); + expect(component.applyDropdownFilter).toHaveBeenCalledWith(_appValue); + _appValue= {"value":"Test"}; + component.applyDropdownFilter(_appValue); + expect(component.applyDropdownFilter).toHaveBeenCalledWith(_appValue); + }); + it('applyFilter should return stubbed value', () => { + spyOn(component, 'applyFilter').and.callThrough(); + component.applyFilter("Test"); + expect(component.applyFilter).toHaveBeenCalledWith("Test"); + }); + it('getAdminApps should return stubbed value', () => { + spyOn(component, 'getAdminApps').and.callThrough(); + component.getAdminApps(); + expect(component.getAdminApps).toHaveBeenCalledWith(); + }); }); + +@Component({selector: 'app-search-users', template: ''}) +class AppSearchUsersStubComponent { +@Input() searchTitle:any; +@Input() isSystemUser:boolean; +@Input() placeHolder:any; + + +} +@Component({selector: 'app-user-details-form', template: ''}) +class AppUsersdetailsFormStubComponent { + +} + diff --git a/portal-FE-common/src/app/pages/web-analytics/web-analytics-details-dialog/web-analytics-details-dialog.component.spec.ts b/portal-FE-common/src/app/pages/web-analytics/web-analytics-details-dialog/web-analytics-details-dialog.component.spec.ts index 4dc85724..95eb021a 100644 --- a/portal-FE-common/src/app/pages/web-analytics/web-analytics-details-dialog/web-analytics-details-dialog.component.spec.ts +++ b/portal-FE-common/src/app/pages/web-analytics/web-analytics-details-dialog/web-analytics-details-dialog.component.spec.ts @@ -39,14 +39,22 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { WebAnalyticsDetailsDialogComponent } from './web-analytics-details-dialog.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('WebAnalyticsDetailsDialogComponent', () => { let component: WebAnalyticsDetailsDialogComponent; let fixture: ComponentFixture; + const userTableAppReport: any = {"appName":"WebNameTest"}; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ WebAnalyticsDetailsDialogComponent ] + declarations: [ WebAnalyticsDetailsDialogComponent ], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -54,6 +62,7 @@ describe('WebAnalyticsDetailsDialogComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(WebAnalyticsDetailsDialogComponent); component = fixture.componentInstance; + component.userTableAppReport = userTableAppReport; fixture.detectChanges(); }); diff --git a/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.spec.ts b/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.spec.ts index 76d44cc0..93fde8dc 100644 --- a/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.spec.ts +++ b/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.spec.ts @@ -39,6 +39,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { WebAnalyticsComponent } from './web-analytics.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('WebAnalyticsComponent', () => { let component: WebAnalyticsComponent; @@ -46,7 +50,9 @@ describe('WebAnalyticsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ WebAnalyticsComponent ] + declarations: [ WebAnalyticsComponent ], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule], + }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/widget-catalog/widget-catalog.component.spec.ts b/portal-FE-common/src/app/pages/widget-catalog/widget-catalog.component.spec.ts index 83de0040..e44c7f82 100644 --- a/portal-FE-common/src/app/pages/widget-catalog/widget-catalog.component.spec.ts +++ b/portal-FE-common/src/app/pages/widget-catalog/widget-catalog.component.spec.ts @@ -1,6 +1,13 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { WidgetCatalogComponent } from './widget-catalog.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { GridsterModule } from 'angular-gridster2'; +import { ElipsisPipe } from 'src/app/shared/pipes/elipsis/elipsis.pipe'; +import { Component, Input } from '@angular/core'; describe('WidgetCatalogComponent', () => { let component: WidgetCatalogComponent; @@ -8,7 +15,8 @@ describe('WidgetCatalogComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ WidgetCatalogComponent ] + declarations: [ WidgetCatalogComponent ,ElipsisPipe,AppDynamicWidgetStubComponent], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule,GridsterModule] }) .compileComponents(); })); @@ -23,3 +31,8 @@ describe('WidgetCatalogComponent', () => { expect(component).toBeTruthy(); }); }); + +@Component({selector: 'app-dynamic-widget', template: ''}) +class AppDynamicWidgetStubComponent { + @Input() widgetType:any; +} diff --git a/portal-FE-common/src/app/pages/widget-onboarding/widget-details-dialog/widget-details-dialog.component.spec.ts b/portal-FE-common/src/app/pages/widget-onboarding/widget-details-dialog/widget-details-dialog.component.spec.ts index 411da1e9..b2f3b4b0 100644 --- a/portal-FE-common/src/app/pages/widget-onboarding/widget-details-dialog/widget-details-dialog.component.spec.ts +++ b/portal-FE-common/src/app/pages/widget-onboarding/widget-details-dialog/widget-details-dialog.component.spec.ts @@ -39,14 +39,23 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { WidgetDetailsDialogComponent } from './widget-details-dialog.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { IWidget } from 'src/app/shared/model/widget-onboarding/widget'; describe('WidgetDetailsDialogComponent', () => { let component: WidgetDetailsDialogComponent; let fixture: ComponentFixture; + const widget: IWidget = {"allUser":true,"name":"WidgetTestName"}; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ WidgetDetailsDialogComponent ] + declarations: [ WidgetDetailsDialogComponent ], + imports:[HttpClientTestingModule,FormsModule,ReactiveFormsModule,NgMaterialModule,BrowserAnimationsModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -54,6 +63,7 @@ describe('WidgetDetailsDialogComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(WidgetDetailsDialogComponent); component = fixture.componentInstance; + component.widget=widget; fixture.detectChanges(); }); diff --git a/portal-FE-common/src/app/pages/widget-onboarding/widget-onboarding.component.spec.ts b/portal-FE-common/src/app/pages/widget-onboarding/widget-onboarding.component.spec.ts index 2fd7ef27..e0df154d 100644 --- a/portal-FE-common/src/app/pages/widget-onboarding/widget-onboarding.component.spec.ts +++ b/portal-FE-common/src/app/pages/widget-onboarding/widget-onboarding.component.spec.ts @@ -38,6 +38,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { WidgetOnboardingComponent } from './widget-onboarding.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('WidgetOnboardingComponent', () => { let component: WidgetOnboardingComponent; @@ -45,7 +49,8 @@ describe('WidgetOnboardingComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ WidgetOnboardingComponent ] + declarations: [ WidgetOnboardingComponent ], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule], }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/pages/widgets/widgets.component.spec.ts b/portal-FE-common/src/app/pages/widgets/widgets.component.spec.ts index 72982a1c..f0aa97a1 100644 --- a/portal-FE-common/src/app/pages/widgets/widgets.component.spec.ts +++ b/portal-FE-common/src/app/pages/widgets/widgets.component.spec.ts @@ -1,6 +1,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { WidgetsComponent } from './widgets.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('WidgetsComponent', () => { let component: WidgetsComponent; @@ -8,7 +10,8 @@ describe('WidgetsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ WidgetsComponent ] + declarations: [ WidgetsComponent ], + imports:[HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.spec.ts b/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.spec.ts index 22a477d3..a553fb45 100644 --- a/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.spec.ts +++ b/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.spec.ts @@ -38,8 +38,14 @@ import { ElipsisPipe } from './elipsis.pipe'; describe('ElipsisPipe', () => { + let pipe; it('create an instance', () => { - const pipe = new ElipsisPipe(); + pipe = new ElipsisPipe(); expect(pipe).toBeTruthy(); }); + it('removeImage should return stubbed value', () => { + spyOn(pipe, 'transform').and.callThrough(); + pipe.transform('PipeTest','2'); + expect(pipe.transform).toHaveBeenCalledWith('PipeTest','2'); + }); }); diff --git a/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.spec.ts b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.spec.ts index d7991933..6a367040 100644 --- a/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.spec.ts +++ b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.spec.ts @@ -39,6 +39,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ListWidgetComponent } from './list-widget.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('ListWidgetComponent', () => { let component: ListWidgetComponent; @@ -46,7 +50,9 @@ describe('ListWidgetComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ListWidgetComponent ] + declarations: [ ListWidgetComponent ], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule] + }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/shared/plugin/plugin.component.spec.ts b/portal-FE-common/src/app/shared/plugin/plugin.component.spec.ts index cc5810c1..59802bab 100644 --- a/portal-FE-common/src/app/shared/plugin/plugin.component.spec.ts +++ b/portal-FE-common/src/app/shared/plugin/plugin.component.spec.ts @@ -39,14 +39,18 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { PluginComponent } from './plugin.component'; +import { ClientPluginLoaderService } from './plugin-loader/client-plugin-loader.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('PluginComponent', () => { let component: PluginComponent; let fixture: ComponentFixture; - + let clientPluginLoaderService: ClientPluginLoaderService; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ PluginComponent ] + declarations: [ PluginComponent ], + providers:[ClientPluginLoaderService], + imports: [HttpClientTestingModule] }) .compileComponents(); })); diff --git a/portal-FE-common/src/app/shared/plugin/plugin.component.ts b/portal-FE-common/src/app/shared/plugin/plugin.component.ts index b64ea7c9..8c6202ec 100644 --- a/portal-FE-common/src/app/shared/plugin/plugin.component.ts +++ b/portal-FE-common/src/app/shared/plugin/plugin.component.ts @@ -44,6 +44,7 @@ import { ViewContainerRef } from '@angular/core'; import { PluginLoaderService } from './plugin-loader/plugin-loader.service'; +import { ClientPluginLoaderService } from './plugin-loader/client-plugin-loader.service'; @Component({ selector: 'app-plugin', @@ -55,7 +56,7 @@ export class PluginComponent implements OnInit { constructor( private injector: Injector, - private pluginLoader: PluginLoaderService + private pluginLoader: ClientPluginLoaderService ) {} ngOnInit() { diff --git a/portal-FE-common/src/app/shared/services/admins/admins.service.spec.ts b/portal-FE-common/src/app/shared/services/admins/admins.service.spec.ts index ea61061b..1d8a643b 100644 --- a/portal-FE-common/src/app/shared/services/admins/admins.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/admins/admins.service.spec.ts @@ -1,12 +1,44 @@ import { TestBed } from '@angular/core/testing'; import { AdminsService } from './admins.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AdminsService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + let service: AdminsService; + beforeEach(() => TestBed.configureTestingModule({ + imports:[HttpClientTestingModule] + })); it('should be created', () => { - const service: AdminsService = TestBed.get(AdminsService); + service = TestBed.get(AdminsService); expect(service).toBeTruthy(); }); + it('getAdminAppsRoles should return stubbed value', () => { + spyOn(service, 'getAdminAppsRoles').and.callThrough(); + service.getAdminAppsRoles("test"); + expect(service.getAdminAppsRoles).toHaveBeenCalledWith("test"); + }); + it('getRolesByApp should return stubbed value', () => { + spyOn(service, 'getRolesByApp').and.callThrough(); + service.getRolesByApp("test"); + expect(service.getRolesByApp).toHaveBeenCalledWith("test"); + }); + + it('updateAdminAppsRoles should return stubbed value', () => { + spyOn(service, 'updateAdminAppsRoles').and.callThrough(); + service.updateAdminAppsRoles("test"); + expect(service.updateAdminAppsRoles).toHaveBeenCalledWith("test"); + }); + + it('isComplexPassword should return stubbed value', () => { + spyOn(service, 'isComplexPassword').and.callThrough(); + service.isComplexPassword("testpassword"); + expect(service.isComplexPassword).toHaveBeenCalledWith("testpassword"); + }); + + it('addNewUser should return stubbed value', () => { + spyOn(service, 'addNewUser').and.callThrough(); + service.addNewUser("testuser","duplicatecheck"); + expect(service.addNewUser).toHaveBeenCalledWith("testuser","duplicatecheck"); + }); }); diff --git a/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.spec.ts b/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.spec.ts index 5f789869..92c0a72c 100644 --- a/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { ApplicationCatalogService } from './application-catalog.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ApplicationCatalogService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: ApplicationCatalogService = TestBed.get(ApplicationCatalogService); diff --git a/portal-FE-common/src/app/shared/services/applications/applications.service.spec.ts b/portal-FE-common/src/app/shared/services/applications/applications.service.spec.ts index 68017384..f4f36e3b 100644 --- a/portal-FE-common/src/app/shared/services/applications/applications.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/applications/applications.service.spec.ts @@ -39,9 +39,10 @@ import { TestBed } from '@angular/core/testing'; import { ApplicationsService } from './applications.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ApplicationsService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: ApplicationsService = TestBed.get(ApplicationsService); diff --git a/portal-FE-common/src/app/shared/services/basic-auth-account/basic-auth-account.service.spec.ts b/portal-FE-common/src/app/shared/services/basic-auth-account/basic-auth-account.service.spec.ts index 4a6c0f43..72267b95 100644 --- a/portal-FE-common/src/app/shared/services/basic-auth-account/basic-auth-account.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/basic-auth-account/basic-auth-account.service.spec.ts @@ -39,9 +39,10 @@ import { TestBed } from '@angular/core/testing'; import { BasicAuthAccountService } from './basic-auth-account.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('BasicAuthAccountService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: BasicAuthAccountService = TestBed.get(BasicAuthAccountService); diff --git a/portal-FE-common/src/app/shared/services/contact-us/contact-us.service.spec.ts b/portal-FE-common/src/app/shared/services/contact-us/contact-us.service.spec.ts index 03d55d05..3a91b523 100644 --- a/portal-FE-common/src/app/shared/services/contact-us/contact-us.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/contact-us/contact-us.service.spec.ts @@ -39,12 +39,34 @@ import { TestBed } from '@angular/core/testing'; import { ContactUsService } from './contact-us.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ContactUsService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: ContactUsService = TestBed.get(ContactUsService); expect(service).toBeTruthy(); }); + + it('addContactUs should return stubbed value', () => { + const service: ContactUsService = TestBed.get(ContactUsService); + spyOn(service, 'addContactUs').and.callThrough(); + service.addContactUs("TEST"); + expect(service.addContactUs).toHaveBeenCalledWith("TEST") + }); + + it('modifyContactUs should return stubbed value', () => { + const service: ContactUsService = TestBed.get(ContactUsService); + spyOn(service, 'modifyContactUs').and.callThrough(); + service.modifyContactUs("TEST"); + expect(service.modifyContactUs).toHaveBeenCalledWith("TEST") + }); + + it('removeContactUs should return stubbed value', () => { + const service: ContactUsService = TestBed.get(ContactUsService); + spyOn(service, 'removeContactUs').and.callThrough(); + service.removeContactUs("TEST"); + expect(service.removeContactUs).toHaveBeenCalledWith("TEST") + }); }); diff --git a/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.spec.ts b/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.spec.ts index d7f33e92..09de2297 100644 --- a/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.spec.ts @@ -1,9 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { ExternalRequestAccessService } from './external-request-access.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ExternalRequestAccessService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: ExternalRequestAccessService = TestBed.get(ExternalRequestAccessService); diff --git a/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.spec.ts b/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.spec.ts index 1280c084..29088672 100644 --- a/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.spec.ts @@ -38,9 +38,13 @@ import { TestBed } from '@angular/core/testing'; import { FunctionalMenuService } from './functional-menu.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; + describe('FunctionalMenuService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({ + imports:[HttpClientTestingModule]} + )); it('should be created', () => { const service: FunctionalMenuService = TestBed.get(FunctionalMenuService); diff --git a/portal-FE-common/src/app/shared/services/get-access/get-access.service.spec.ts b/portal-FE-common/src/app/shared/services/get-access/get-access.service.spec.ts index 2f0c96a8..f98d3360 100644 --- a/portal-FE-common/src/app/shared/services/get-access/get-access.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/get-access/get-access.service.spec.ts @@ -1,9 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { GetAccessService } from './get-access.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('GetAccessService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: GetAccessService = TestBed.get(GetAccessService); diff --git a/portal-FE-common/src/app/shared/services/global-search/global-search.service.spec.ts b/portal-FE-common/src/app/shared/services/global-search/global-search.service.spec.ts index 50ccebbf..4e384c10 100644 --- a/portal-FE-common/src/app/shared/services/global-search/global-search.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/global-search/global-search.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { GlobalSearchService } from './global-search.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('GlobalSearchService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: GlobalSearchService = TestBed.get(GlobalSearchService); diff --git a/portal-FE-common/src/app/shared/services/manifest/manifest.service.spec.ts b/portal-FE-common/src/app/shared/services/manifest/manifest.service.spec.ts index a5ad81b1..85e6e294 100644 --- a/portal-FE-common/src/app/shared/services/manifest/manifest.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/manifest/manifest.service.spec.ts @@ -1,9 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { ManifestService } from './manifest.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ManifestService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: ManifestService = TestBed.get(ManifestService); diff --git a/portal-FE-common/src/app/shared/services/menus/menus.service.spec.ts b/portal-FE-common/src/app/shared/services/menus/menus.service.spec.ts index b624236a..ad345d11 100644 --- a/portal-FE-common/src/app/shared/services/menus/menus.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/menus/menus.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { MenusService } from './menus.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('MenusService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: MenusService = TestBed.get(MenusService); diff --git a/portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts b/portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts index 439a9480..aa3229eb 100644 --- a/portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/microservice/microservice.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { MicroserviceService } from './microservice.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('MicroserviceService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: MicroserviceService = TestBed.get(MicroserviceService); diff --git a/portal-FE-common/src/app/shared/services/notification/notification.service.spec.ts b/portal-FE-common/src/app/shared/services/notification/notification.service.spec.ts index b8f0d334..fdaec249 100644 --- a/portal-FE-common/src/app/shared/services/notification/notification.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/notification/notification.service.spec.ts @@ -39,9 +39,10 @@ import { TestBed } from '@angular/core/testing'; import { NotificationService } from './notification.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('NotificationService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: NotificationService = TestBed.get(NotificationService); diff --git a/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.spec.ts b/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.spec.ts index e984467e..932d01ec 100644 --- a/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.spec.ts @@ -1,9 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { PortalAdminsService } from './portal-admin.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AdminsService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: PortalAdminsService = TestBed.get(PortalAdminsService); diff --git a/portal-FE-common/src/app/shared/services/role/role.service.spec.ts b/portal-FE-common/src/app/shared/services/role/role.service.spec.ts index e5935616..96802f84 100644 --- a/portal-FE-common/src/app/shared/services/role/role.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/role/role.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { RoleService } from './role.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('RoleService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: RoleService = TestBed.get(RoleService); diff --git a/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.spec.ts b/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.spec.ts index dbeb9b6a..a473acde 100644 --- a/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { SchedulerService } from './scheduler.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('SchedulerService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: SchedulerService = TestBed.get(SchedulerService); diff --git a/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.spec.ts b/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.spec.ts index 065e6e56..15fffb63 100644 --- a/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { SidebarService } from './sidebar.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('SidenavService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: SidebarService = TestBed.get(SidebarService); diff --git a/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.spec.ts b/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.spec.ts index 70ae8043..55a7ba0b 100644 --- a/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.spec.ts @@ -38,12 +38,20 @@ import { TestBed } from '@angular/core/testing'; import { AddTabFunctionService } from './add-tab-function.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AddTabFunctionService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: AddTabFunctionService = TestBed.get(AddTabFunctionService); expect(service).toBeTruthy(); }); + + it('filter should return stubbed value', () => { + const service: AddTabFunctionService = TestBed.get(AddTabFunctionService); + spyOn(service, 'filter').and.callThrough(); + service.filter("TEST"); + expect(service.filter).toHaveBeenCalledWith("TEST") + }); }); diff --git a/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.spec.ts b/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.spec.ts index b1d5e6bd..265ae405 100644 --- a/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.spec.ts @@ -38,12 +38,30 @@ import { TestBed } from '@angular/core/testing'; import { UserProfileService } from './user-profile.service'; - +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { Observable } from 'rxjs'; +import 'rxjs/add/observable/of'; describe('UserProfileService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + // set the value to return when the `getValue` spy is called. + const stubValue = 'stub value'; + const NODE_CONFIG: Array = []; + beforeEach(() => + { + TestBed.configureTestingModule({imports:[HttpClientTestingModule]}) + + } + + ); it('should be created', () => { const service: UserProfileService = TestBed.get(UserProfileService); expect(service).toBeTruthy(); }); + + it('getUserAppRoles should return stubbed value', () => { + const service: UserProfileService = TestBed.get(UserProfileService); + spyOn(service, 'getUserAppRoles').and.callThrough(); + service.getUserAppRoles("TEST"); + expect(service.getUserAppRoles).toHaveBeenCalledWith("TEST") + }); }); diff --git a/portal-FE-common/src/app/shared/services/userbar/userbar.service.spec.ts b/portal-FE-common/src/app/shared/services/userbar/userbar.service.spec.ts index 24329626..924c85c3 100644 --- a/portal-FE-common/src/app/shared/services/userbar/userbar.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/userbar/userbar.service.spec.ts @@ -1,9 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { UserbarService } from './userbar.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('UserbarService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: UserbarService = TestBed.get(UserbarService); diff --git a/portal-FE-common/src/app/shared/services/users/users.service.spec.ts b/portal-FE-common/src/app/shared/services/users/users.service.spec.ts index c1f41d8a..cd30d995 100644 --- a/portal-FE-common/src/app/shared/services/users/users.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/users/users.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { UsersService } from './users.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('UsersService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: UsersService = TestBed.get(UsersService); diff --git a/portal-FE-common/src/app/shared/services/utils/utils.service.spec.ts b/portal-FE-common/src/app/shared/services/utils/utils.service.spec.ts index 102bf3d4..1d4d168d 100644 --- a/portal-FE-common/src/app/shared/services/utils/utils.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/utils/utils.service.spec.ts @@ -1,9 +1,10 @@ import { TestBed } from '@angular/core/testing'; import { UtilsService } from './utils.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('UtilsService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: UtilsService = TestBed.get(UtilsService); diff --git a/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.spec.ts b/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.spec.ts index 0c9b86bf..45e0c5b5 100644 --- a/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.spec.ts @@ -39,9 +39,10 @@ import { TestBed } from '@angular/core/testing'; import { WebAnalyticsService } from './web-analytics.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('WebAnalyticsService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: WebAnalyticsService = TestBed.get(WebAnalyticsService); diff --git a/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.spec.ts b/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.spec.ts index fb87e8b9..bceef7c7 100644 --- a/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.spec.ts @@ -38,9 +38,10 @@ import { TestBed } from '@angular/core/testing'; import { WidgetCatalogService } from './widget-catalog.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('WidgetCatalogService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: WidgetCatalogService = TestBed.get(WidgetCatalogService); diff --git a/portal-FE-common/src/app/shared/services/widget-onboarding/widget-onboarding.service.spec.ts b/portal-FE-common/src/app/shared/services/widget-onboarding/widget-onboarding.service.spec.ts index 90e53269..f7214a5b 100644 --- a/portal-FE-common/src/app/shared/services/widget-onboarding/widget-onboarding.service.spec.ts +++ b/portal-FE-common/src/app/shared/services/widget-onboarding/widget-onboarding.service.spec.ts @@ -39,9 +39,10 @@ import { TestBed } from '@angular/core/testing'; import { WidgetOnboardingService } from './widget-onboarding.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('WidgetOnboardingService', () => { - beforeEach(() => TestBed.configureTestingModule({})); + beforeEach(() => TestBed.configureTestingModule({imports:[HttpClientTestingModule]})); it('should be created', () => { const service: WidgetOnboardingService = TestBed.get(WidgetOnboardingService); diff --git a/portal-FE-os/package.json b/portal-FE-os/package.json index 265cab72..77cef690 100644 --- a/portal-FE-os/package.json +++ b/portal-FE-os/package.json @@ -5,9 +5,10 @@ "ng": "ng", "start": "ng serve --host www.portal.onap.org --port 8989 --open", "build": "ng build --prod --aot=false --build-optimizer=false", - "test": "ng test", + "test": "ng test --watch=false --code-coverage --browsers=ChromeHeadless", "lint": "ng lint", - "e2e": "ng e2e" + "e2e": "ng e2e", + "sonar": "sonar-scanner" }, "private": true, "dependencies": { @@ -65,6 +66,7 @@ "karma-jasmine": "~1.1.2", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.4.0", + "sonar-scanner": "^3.1.0", "ts-node": "~7.0.0", "tslint": "~5.11.0", "typescript": "~3.1.6" diff --git a/portal-FE-os/pom.xml b/portal-FE-os/pom.xml index 626addb4..21bdd508 100644 --- a/portal-FE-os/pom.xml +++ b/portal-FE-os/pom.xml @@ -10,6 +10,14 @@ UTF-8 false false + coverage/lcov.info + src + portal-FE-os + portal-FE-os + **/node_modules/**,**/*.spec.ts,**/*.module.ts,**/environment.prod.ts,**/*.js,**/main.ts,**/header-interceptor.ts,**/dynamic-widget.component.ts + **/*.spec.ts + src + UTF-8 @@ -97,6 +105,19 @@ install + + + npm run test + + npm + + + generate-resources + + + run-script test + + npm build diff --git a/portal-FE-os/src/app/app.component.spec.ts b/portal-FE-os/src/app/app.component.spec.ts index afc476fd..cd96a77d 100644 --- a/portal-FE-os/src/app/app.component.spec.ts +++ b/portal-FE-os/src/app/app.component.spec.ts @@ -34,7 +34,7 @@ * ============LICENSE_END============================================ * * - */s + */ import { TestBed, async } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; @@ -56,17 +56,4 @@ describe('AppComponent', () => { const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); }); - - it(`should have as title 'portal-FE-os'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('portal-FE-os'); - }); - - it('should render title in a h1 tag', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to portal-FE-os!'); - }); }); diff --git a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.spec.ts b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.spec.ts index 0ea27629..629e5fa6 100644 --- a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.spec.ts +++ b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.spec.ts @@ -39,25 +39,94 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ApplicationDetailsDialogComponent } from './application-details-dialog.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { FormsModule } from '@angular/forms'; +import { NgbActiveModal, NgbModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { IApplications } from 'src/app/shared/model/applications-onboarding/applications'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { NgbModalBackdrop } from '@ng-bootstrap/ng-bootstrap/modal/modal-backdrop'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; + describe('ApplicationDetailsDialogComponent', () => { let component: ApplicationDetailsDialogComponent; let fixture: ComponentFixture; + const applicationObj: IApplications = {"id":"testID"}; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ApplicationDetailsDialogComponent ] - }) + declarations: [ ApplicationDetailsDialogComponent,InformationModalComponent,ConfirmationModalComponent], + imports: [NgMaterialModule,FormsModule,HttpClientTestingModule,NgbModule.forRoot()], + providers: [NgbActiveModal] + }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent] } }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(ApplicationDetailsDialogComponent); component = fixture.componentInstance; + component.applicationObj = applicationObj; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + it('removeImage should return stubbed value', () => { + spyOn(component, 'removeImage').and.callThrough(); + component.removeImage(); + expect(component.removeImage).toHaveBeenCalledWith(); + }); + it('saveChanges should return stubbed value', () => { + component.applicationObj.isCentralAuth = true; + component.applicationObj.isEnabled = false; + spyOn(component, 'saveChanges').and.callThrough(); + component.saveChanges(); + expect(component.saveChanges).toHaveBeenCalledWith(); + component.applicationObj.isEnabled = true; + component.applicationObj.url = 'www.test.com' + component.applicationObj.restrictedApp =true; + + //spyOn(component, 'saveChanges').and.callThrough(); + component.saveChanges(); + expect(component.saveChanges).toHaveBeenCalledWith(); + component.applicationObj.isCentralAuth = false; + component.applicationObj.url = 'test' + component.applicationObj.restrictedApp =false; + component.applicationObj.isOpen = true; + component.isEditMode =true; + //spyOn(component, 'saveChanges').and.callThrough(); + component.saveChanges(); + expect(component.saveChanges).toHaveBeenCalledWith(); + }); + it('saveChanges Central Auth is disabled', () => { + component.applicationObj.isCentralAuth = false; + component.applicationObj.isEnabled = false; + spyOn(component, 'saveChanges').and.callThrough(); + component.saveChanges(); + expect(component.saveChanges).toHaveBeenCalledWith(); + component.applicationObj.isEnabled = true; + component.applicationObj.restrictedApp = true; + component.saveChanges(); + expect(component.saveChanges).toHaveBeenCalledWith(); + + }); + + it('saveChanges URL validation changes', () => { + component.applicationObj.isCentralAuth = true; + component.applicationObj.isEnabled = true; + component.applicationObj.name ='test'; + component.applicationObj.url = 'https://www.test.com' + component.applicationObj.username ='test' + component.applicationObj.nameSpace ='ONAP' + spyOn(component, 'saveChanges').and.callThrough(); + component.saveChanges(); + expect(component.saveChanges).toHaveBeenCalledWith(); + component.applicationObj.restrictedApp = false; + component.isEditMode = true; + component.saveChanges(); + expect(component.saveChanges).toHaveBeenCalledWith(); + }); }); diff --git a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts index 60654461..39d2ffde 100644 --- a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts +++ b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts @@ -36,12 +36,13 @@ * */ -import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter, PLATFORM_ID, Inject, Injector} from '@angular/core'; import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { IApplications } from 'src/app/shared/model/applications-onboarding/applications'; import { ApplicationsService } from 'src/app/shared/services'; import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { isPlatformBrowser } from '@angular/common'; @Component({ selector: 'app-application-details-dialog', @@ -59,9 +60,15 @@ export class ApplicationDetailsDialogComponent implements OnInit { isSaving: boolean = false; originalImage: any; ECOMP_URL_REGEX = "/^((?:https?\:\/\/|ftp?\:\/\/)?(w{3}.)?(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)[^-_.]$/i"; + private ngbModal:NgbModal; - constructor(public activeModal: NgbActiveModal, public ngbModal: NgbModal, - public applicationsService : ApplicationsService) { } + constructor(public activeModal: NgbActiveModal, + public applicationsService : ApplicationsService,@Inject(PLATFORM_ID)private platformId:Object,private injector:Injector) { + if(isPlatformBrowser(this.platformId)) + { + this.ngbModal = this.injector.get(NgbModal); + } + } @Input() applicationObj: IApplications; @Output() passEntry: EventEmitter = new EventEmitter(); diff --git a/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.spec.ts b/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.spec.ts index 8e198387..3f750992 100644 --- a/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.spec.ts +++ b/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.spec.ts @@ -39,6 +39,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ApplicationOnboardingComponent } from './application-onboarding.component'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('ApplicationOnboardingComponent', () => { let component: ApplicationOnboardingComponent; @@ -46,7 +49,8 @@ describe('ApplicationOnboardingComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ApplicationOnboardingComponent ] + declarations: [ ApplicationOnboardingComponent ], + imports: [NgMaterialModule,HttpClientTestingModule,BrowserAnimationsModule] }) .compileComponents(); })); diff --git a/portal-FE-os/src/app/pages/pages.component.spec.ts b/portal-FE-os/src/app/pages/pages.component.spec.ts index 1bef834a..25383aa3 100644 --- a/portal-FE-os/src/app/pages/pages.component.spec.ts +++ b/portal-FE-os/src/app/pages/pages.component.spec.ts @@ -38,6 +38,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { PagesComponent } from './pages.component'; +import { Component } from '@angular/core'; describe('PagesComponent', () => { let component: PagesComponent; @@ -45,7 +46,7 @@ describe('PagesComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ PagesComponent ] + declarations: [ PagesComponent,RouterOutletStubComponent ] }) .compileComponents(); })); @@ -60,3 +61,6 @@ describe('PagesComponent', () => { expect(component).toBeTruthy(); }); }); + +@Component({selector: 'router-outlet', template: ''}) +class RouterOutletStubComponent { } diff --git a/portal-FE-os/src/app/pages/users/new-user-modal/new-user-modal.component.spec.ts b/portal-FE-os/src/app/pages/users/new-user-modal/new-user-modal.component.spec.ts index beb998cf..85a2d9e8 100644 --- a/portal-FE-os/src/app/pages/users/new-user-modal/new-user-modal.component.spec.ts +++ b/portal-FE-os/src/app/pages/users/new-user-modal/new-user-modal.component.spec.ts @@ -38,6 +38,13 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NewUserModalComponent } from './new-user-modal.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { Component, Input } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { MatRadioChange } from '@angular/material'; describe('NewUserModalComponent', () => { let component: NewUserModalComponent; @@ -45,7 +52,9 @@ describe('NewUserModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ NewUserModalComponent ] + declarations: [ NewUserModalComponent,AppSearchUsersStubComponent,AppUserdetailsFormStubComponent ], + imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule], + providers:[NgbActiveModal] }) .compileComponents(); })); @@ -59,4 +68,67 @@ describe('NewUserModalComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('addNewUser should return stubbed value', () => { + spyOn(component, 'addNewUser').and.callThrough(); + component.addNewUser(true); + expect(component.addNewUser).toHaveBeenCalledWith(true); + }); + + it('changeSelectedUser should return stubbed value', () => { + spyOn(component, 'changeSelectedUser').and.callThrough(); + let user = {}; + component.changeSelectedUser(user); + expect(component.changeSelectedUser).toHaveBeenCalledWith(user); + user = {"firstName":"FirstTestName","lastName":"LastTestName","orgUserId":"TestOrgId"}; + component.changeSelectedUser(user); + expect(component.changeSelectedUser).toHaveBeenCalledWith(user); + + }); + + // it('searchUserRadioChange should return stubbed value', () => { + // spyOn(component, 'searchUserRadioChange').and.callThrough(); + // MatRadio = {"value":""}; + // component.searchUserRadioChange(eventCheck); + // expect(component.searchUserRadioChange).toHaveBeenCalledWith(event); + // event = {"value":"System"}; + // component.searchUserRadioChange(event); + // expect(component.searchUserRadioChange).toHaveBeenCalledWith(event); + + // }); + + it('navigateBack should return stubbed value', () => { + spyOn(component, 'navigateBack').and.callThrough(); + component.navigateBack(); + expect(component.navigateBack).toHaveBeenCalledWith(); + }); + + it('roleSelectChange should return stubbed value', () => { + spyOn(component, 'roleSelectChange').and.callThrough(); + let element = {"id":2}; + component.roleSelectChange(element); + expect(component.roleSelectChange).toHaveBeenCalledWith(element); + }); + + it('getUserAppsRoles should return stubbed value', () => { + spyOn(component, 'getUserAppsRoles').and.callThrough(); + component.changedSelectedUser = 'Test'; + component.getUserAppsRoles(); + expect(component.getUserAppsRoles).toHaveBeenCalledWith(); + }); + + + }); + +@Component({selector: 'app-search-users', template: ''}) +class AppSearchUsersStubComponent { + @Input() searchTitle:any; + @Input() isSystemUser:any; + @Input() placeHolder:any; +} + +@Component({selector: 'app-user-details-form', template: ''}) +class AppUserdetailsFormStubComponent { + +} diff --git a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.spec.ts b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.spec.ts index 3262174f..b687cd5e 100644 --- a/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.spec.ts +++ b/portal-FE-os/src/app/pages/users/user-details-form/user-details-form.component.spec.ts @@ -1,6 +1,11 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UserDetailsFormComponent } from './user-details-form.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { NgMaterialModule } from 'src/app/ng-material-module'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; describe('UserDetailsFormComponent', () => { let component: UserDetailsFormComponent; @@ -8,7 +13,9 @@ describe('UserDetailsFormComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ UserDetailsFormComponent ] + declarations: [ UserDetailsFormComponent ], + imports:[HttpClientTestingModule,FormsModule,ReactiveFormsModule,NgMaterialModule,BrowserAnimationsModule], + providers:[NgbActiveModal] }) .compileComponents(); })); diff --git a/portal-FE-os/src/testing/router-link-directive-stub.ts b/portal-FE-os/src/testing/router-link-directive-stub.ts new file mode 100644 index 00000000..73e75cbe --- /dev/null +++ b/portal-FE-os/src/testing/router-link-directive-stub.ts @@ -0,0 +1,14 @@ +import { Directive, Input, HostListener } from "@angular/core"; + +@Directive({ + selector: '[routerLink]' + }) + export class RouterLinkDirectiveStub { + @Input('routerLink') linkParams: any; + navigatedTo: any = null; + + @HostListener('click') + onClick() { + this.navigatedTo = this.linkParams; + } + } \ No newline at end of file -- 2.16.6