-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
251 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable, Injector } from '@angular/core'; | ||
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http'; | ||
|
||
import { Observable, of } from 'rxjs'; | ||
|
||
|
||
@Injectable() | ||
export class HttpRequestInterceptorMock implements HttpInterceptor { | ||
constructor(private injector: Injector) { } | ||
|
||
intercept(request: HttpRequest<any>, next: HttpHandler): | ||
Observable<HttpEvent<any>> { | ||
if (request.url && | ||
request.url.includes(`projects/test-project/scenarios/test-scenario/notification`)) { | ||
return of(new HttpResponse({ status: 200, body: [] })); | ||
} | ||
if (request.url && | ||
request.url.includes('projects/test-project/scenarios/test-scenario/items/test-item/share-tokens')) { | ||
return of(new HttpResponse({ status: 200, body: [] })); | ||
} | ||
if (request.url && | ||
request.url.includes('api-tokens')) { | ||
return of(new HttpResponse({ status: 200, body: [] })); | ||
} | ||
if (request.url && | ||
request.url.includes('projects/test-project/scenarios/test-scenario/items/test-item/custom-chart-settings')) { | ||
return of(new HttpResponse({ status: 200 })); | ||
} | ||
|
||
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { TestBed, async } from '@angular/core/testing'; | ||
import { PactWeb, Matchers } from '@pact-foundation/pact-web'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { ItemsApiService } from './items-api.service'; | ||
|
||
describe('Items', () => { | ||
|
||
let provider; | ||
|
||
beforeAll((done) => { | ||
provider = new PactWeb({ | ||
port: 1234, | ||
host: '127.0.0.1', | ||
}); | ||
|
||
// required for slower CI environments | ||
setTimeout(done, 4000); | ||
|
||
// Required if run with `singleRun: false` | ||
provider.removeInteractions(); | ||
}); | ||
|
||
afterAll((done) => { | ||
provider.finalize().then(done, e => done.fail(e)); | ||
}); | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
HttpClientModule | ||
], | ||
providers: [ | ||
ItemsApiService | ||
], | ||
}); | ||
})); | ||
|
||
afterEach((done) => { | ||
provider.verify().then(done, e => done.fail(e)); | ||
}); | ||
|
||
describe('/projects/:projectName/scenarios/:scenarionName/items/:id/share-tokens', () => { | ||
describe('GET /projects/:projectName/scenarios/:scenarionName/items/:id/share-tokens', () => { | ||
beforeAll((done) => { | ||
provider.addInteraction({ | ||
state: 'there is at least one existing test item', | ||
uponReceiving: 'a request for test item', | ||
withRequest: { | ||
method: 'GET', | ||
path: '/projects/test-project/scenarios/test-scenario/items/28b32386-2c69-41fc-ab98-8b16ef4823af/share-tokens' | ||
}, | ||
willRespondWith: { | ||
status: 200, | ||
body: Matchers.eachLike({ | ||
name: 'token name', | ||
id: 'e3d1cde2-6079-4b01-8592-4bde15ae6ed7', | ||
token: '93ca7b28a9a97d0f80ec815ddcf046274dcb25fdef5583f7b15fa04c6990300a20a08281fa5838' | ||
}) | ||
}, | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}).then(done, e => done.fail(e)); | ||
}); | ||
it('should return item share tokens', (done) => { | ||
const itemApiService: ItemsApiService = TestBed.get(ItemsApiService); | ||
itemApiService.fetchItemShareTokens('test-project', 'test-scenario', '28b32386-2c69-41fc-ab98-8b16ef4823af').subscribe(response => { | ||
done(); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
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
29 changes: 29 additions & 0 deletions
29
src/app/scenario/delete-scenario/delete-scenario.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,29 @@ | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { RouterModule } from '@angular/router'; | ||
import { DeleteScenarioComponent } from './delete-scenario.component'; | ||
|
||
|
||
describe('DeleteScenarioComponent', () => { | ||
let component: DeleteScenarioComponent; | ||
let fixture: ComponentFixture<DeleteScenarioComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [DeleteScenarioComponent], | ||
imports: [FormsModule, ReactiveFormsModule, HttpClientModule, RouterModule.forRoot([])] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DeleteScenarioComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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
Oops, something went wrong.