fix failing tests replace ajax with spy

This commit is contained in:
Eugenio Romano
2018-05-21 15:44:38 +01:00
parent 266ad76ad9
commit adc1d9cb95
3 changed files with 8 additions and 297 deletions

View File

@@ -22,15 +22,18 @@ import * as analyticParamsMock from '../../mock';
import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { AnalyticsService } from '../services/analytics.service';
import { Observable } from 'rxjs/Observable';
declare let jasmine: any;
describe('AnalyticsReportParametersComponent', () => {
fdescribe('AnalyticsReportParametersComponent', () => {
let component: AnalyticsReportParametersComponent;
let fixture: ComponentFixture<AnalyticsReportParametersComponent>;
let element: HTMLElement;
let validForm = false;
let service: AnalyticsService;
setupTestBed({
imports: [InsightsTestingModule]
@@ -38,6 +41,7 @@ describe('AnalyticsReportParametersComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsReportParametersComponent);
service = TestBed.get(AnalyticsService);
component = fixture.componentInstance;
element = fixture.nativeElement;
spyOn(component, 'isFormValid').and.callFake(() => {
@@ -444,6 +448,7 @@ describe('AnalyticsReportParametersComponent', () => {
}));
it('Should be able to change the report title', (done) => {
spyOn(service, 'updateReport').and.returnValue(Observable.of(analyticParamsMock.reportDefParamStatus));
let title: HTMLElement = element.querySelector('h4');
title.click();
@@ -464,12 +469,6 @@ describe('AnalyticsReportParametersComponent', () => {
expect(titleChanged.textContent.trim()).toEqual('FAKE_TEST_NAME');
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'json',
responseText: analyticParamsMock.reportDefParamStatus
});
});
xit('Should show a dialog to allowing report save', async(() => {