diff options
Diffstat (limited to 'portal-FE-common/src/app')
76 files changed, 925 insertions, 117 deletions
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<HeaderComponent>; + 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<AccountAddDetailsComponent>; + 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<DashboardWidgetCatalogComponent>; + 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<FunctionalMenuDialogComponent>; + 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<MicroserviceAddDetailsComponent>; + 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<SchedulerComponent>; + 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<NewNotificationModalComponent>; + let fixture1: ComponentFixture<NewNotificationModalComponent>; + 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<BulkUserComponent>; + 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<WebAnalyticsDetailsDialogComponent>; + 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<WidgetDetailsDialogComponent>; + 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<PluginComponent>; - + 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<any> = []; + 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); |