diff options
-rw-r--r-- | portal-FE-common/src/app/pages/widget-onboarding/widget-onboarding.component.spec.ts | 51 | ||||
-rw-r--r-- | portal-FE-os/pom.xml | 2 |
2 files changed, 52 insertions, 1 deletions
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 e0df154d..1ecba2c2 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 @@ -42,17 +42,59 @@ 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 { WidgetOnboardingService } from 'src/app/shared/services/widget-onboarding/widget-onboarding.service'; +import { Observable } from 'rxjs'; +import { HttpClientModule } from '@angular/common/http'; describe('WidgetOnboardingComponent', () => { let component: WidgetOnboardingComponent; let fixture: ComponentFixture<WidgetOnboardingComponent>; + let widgetList = [{"id" :"1", + "name":"ONAP-A", + "desc" :"desc", + "fileLocation" : "fileLocation", + "allowAllUser" : "allowAllUser", + "serviceId" : "serviceId", + "serviceURL" : "serviceURL", + "sortOrder" : "sortOrder", + "statusCode" : "statusCode", + "widgetRoles": "widgetRoles", + "appContent" : "appContent", + "appName" : "appName", + "file" : "file", + "allUser": false, + "saving": "saving"},{"id" :"1", + "name":"ONAP-B", + "desc" :"desc", + "fileLocation" : "fileLocation", + "allowAllUser" : "allowAllUser", + "serviceId" : "serviceId", + "serviceURL" : "serviceURL", + "sortOrder" : "sortOrder", + "statusCode" : "statusCode", + "widgetRoles": "widgetRoles", + "appContent" : "appContent", + "appName" : "appName", + "file" : "file", + "allUser": false, + "saving": "saving"}] + beforeEach(async(() => { + let widgetOnboardingService: WidgetOnboardingService; + + // widgetOnboardingService = jasmine.createSpyObj('WidgetOnboardingService', ['getManagedWidgets']); + //widgetOnboardingService.getManagedWidgets.and.returnValue(Observable.of(widgetList)); TestBed.configureTestingModule({ declarations: [ WidgetOnboardingComponent ], - imports:[HttpClientTestingModule,FormsModule,NgMaterialModule,BrowserAnimationsModule], + imports:[HttpClientModule,FormsModule,NgMaterialModule,BrowserAnimationsModule], + providers:[WidgetOnboardingService] }) .compileComponents(); + + + widgetOnboardingService = TestBed.get(WidgetOnboardingService); + spyOn(widgetOnboardingService, 'getManagedWidgets').and.returnValue(Observable.of(widgetList)); })); beforeEach(() => { @@ -61,7 +103,14 @@ describe('WidgetOnboardingComponent', () => { fixture.detectChanges(); }); + + it('should create', () => { expect(component).toBeTruthy(); }); + it('getOnboardingWidgets should return stubbed value', () => { + spyOn(component, 'getOnboardingWidgets').and.callThrough(); + component.getOnboardingWidgets(); + expect(component.getOnboardingWidgets).toHaveBeenCalledWith(); + }); }); diff --git a/portal-FE-os/pom.xml b/portal-FE-os/pom.xml index 57507bfb..85def902 100644 --- a/portal-FE-os/pom.xml +++ b/portal-FE-os/pom.xml @@ -17,7 +17,9 @@ <sonar.exclusions>**/node_modules/**,**/*.spec.ts,**/*.module.ts,**/environment.prod.ts,**/*.js,**/main.ts,**/header-interceptor.ts,**/dynamic-widget.component.ts</sonar.exclusions> <sonar.test.inclusions>**/*.spec.ts</sonar.test.inclusions> <sonar.tests>src</sonar.tests> + <sonar.scm.exclusions.disabled>true</sonar.scm.exclusions.disabled> <sonar.sourceEncoding>UTF-8</sonar.sourceEncoding> + <sonar.nodejs.executable>node</sonar.nodejs.executable> </properties> <build> |