-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#614 added mock data stubs for test errors
- Loading branch information
1 parent
56f88fb
commit 5edf8ab
Showing
13 changed files
with
678 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/lib/interceptors/mock-test-data.interceptor.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Injectable, Injector } from '@angular/core'; | ||
import { | ||
HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, | ||
HttpResponse | ||
} from '@angular/common/http'; | ||
|
||
import { BehaviorSubject, Observable, of, Subject, throwError } from 'rxjs'; | ||
import * as datasourceStubData from '../../../stubs/datasources/datasources.json'; | ||
import * as statisticsLoadedStubData from '../../../stubs/statistics/loaded/loaded.json'; | ||
import * as statisticsSummaryStubData from '../../../stubs/statistics/summary/summary.json'; | ||
|
||
@Injectable() | ||
export class MockTestDataInterceptor implements HttpInterceptor { | ||
constructor(private injector: Injector) {} | ||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | ||
if(request.method === "GET" && request.url.indexOf("/data-sources") > 0) { | ||
console.log('intercepted datasource http request: ', request); | ||
return of(new HttpResponse({ status: 200, body: datasourceStubData })); | ||
} | ||
if(request.method === "GET" && request.url.indexOf("/statistics/loaded") > 0) { | ||
console.log('intercepted loaded statistics http request: ', request); | ||
return of(new HttpResponse({ status: 200, body: statisticsLoadedStubData })); | ||
} | ||
if(request.method === "GET" && request.url.indexOf("/statistics/summary") > 0) { | ||
console.log('intercepted summary statistics http request: ', request); | ||
return of(new HttpResponse({ status: 200, body: statisticsSummaryStubData })); | ||
} | ||
return next.handle(request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/lib/statistics/cross-source/sz-cross-source-results.data-table.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { HTTP_INTERCEPTORS } from '@angular/common/http'; | ||
import { MockTestDataInterceptor } from '../../interceptors/mock-test-data.interceptor.service'; | ||
|
||
import { SzCrossSourceResultsDataTable } from './sz-cross-source-results.data-table'; | ||
import { SenzingSdkModule } from '../../sdk.module'; | ||
|
||
describe('SzCrossSourceResultsDataTable', () => { | ||
let component: SzCrossSourceResultsDataTable; | ||
let fixture: ComponentFixture<SzCrossSourceResultsDataTable>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [SenzingSdkModule.forRoot()], | ||
providers: [ | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: MockTestDataInterceptor, | ||
multi: true | ||
} | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SzCrossSourceResultsDataTable); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
afterEach(() => { | ||
fixture.destroy(); | ||
}); | ||
|
||
it('should create', () => { | ||
// test fails on CI only (issue #75) | ||
// temporarily removing until more is known | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/lib/statistics/cross-source/sz-cross-source-select.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { HTTP_INTERCEPTORS } from '@angular/common/http'; | ||
import { MockTestDataInterceptor } from '../../interceptors/mock-test-data.interceptor.service'; | ||
|
||
import { SzCrossSourceSelectComponent } from './sz-cross-source-select.component'; | ||
import { SenzingSdkModule } from '../../sdk.module'; | ||
|
||
describe('SzCrossSourceSelectComponent', () => { | ||
let component: SzCrossSourceSelectComponent; | ||
let fixture: ComponentFixture<SzCrossSourceSelectComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [SenzingSdkModule.forRoot()], | ||
providers: [ | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: MockTestDataInterceptor, | ||
multi: true | ||
} | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SzCrossSourceSelectComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
afterEach(() => { | ||
fixture.destroy(); | ||
}); | ||
|
||
it('should create', () => { | ||
// test fails on CI only (issue #75) | ||
// temporarily removing until more is known | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/lib/statistics/cross-source/sz-cross-source-statistics.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { HTTP_INTERCEPTORS } from '@angular/common/http'; | ||
import { MockTestDataInterceptor } from '../../interceptors/mock-test-data.interceptor.service'; | ||
|
||
import { SzCrossSourceStatistics } from './sz-cross-source-statistics.component'; | ||
import { SenzingSdkModule } from '../../sdk.module'; | ||
|
||
describe('SzCrossSourceStatistics', () => { | ||
let component: SzCrossSourceStatistics; | ||
let fixture: ComponentFixture<SzCrossSourceStatistics>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [SenzingSdkModule.forRoot()], | ||
providers: [ | ||
{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: MockTestDataInterceptor, | ||
multi: true | ||
} | ||
] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SzCrossSourceStatistics); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
afterEach(() => { | ||
fixture.destroy(); | ||
}); | ||
|
||
it('should create', () => { | ||
// test fails on CI only (issue #75) | ||
// temporarily removing until more is known | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
13 changes: 11 additions & 2 deletions
13
src/lib/summary/cross-source/sz-cross-source-summary.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"data": { | ||
"dataSources": [ | ||
"TRUTHSET1", | ||
"TRUTHSET2", | ||
"TRUTHSET3" | ||
], | ||
"dataSourceDetails": { | ||
"TRUTHSET1": { | ||
"dataSourceCode": "TRUTHSET1", | ||
"dataSourceId": 1006 | ||
}, | ||
"TRUTHSET2": { | ||
"dataSourceCode": "TRUTHSET2", | ||
"dataSourceId": 1007 | ||
}, | ||
"TRUTHSET3": { | ||
"dataSourceCode": "TRUTHSET3", | ||
"dataSourceId": 1008 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.