mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-31 00:23:57 +00:00
Try to test http service
This commit is contained in:
parent
b60d2362ef
commit
d24a6aeed6
@ -1,15 +1,50 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
import { TestBed, inject, async } from '@angular/core/testing';
|
||||
import { HttpClientModule} from '@angular/common/http';
|
||||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
||||
|
||||
import { ApplianceService } from './appliance.service';
|
||||
import { Server } from '../models/server';
|
||||
import { HttpServer } from './http-server.service';
|
||||
import { Http, HttpModule, XHRBackend} from '@angular/http';
|
||||
import { MockBackend, MockConnection } from '@angular/http/testing';
|
||||
|
||||
describe('ApplianceService', () => {
|
||||
beforeEach(() => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ApplianceService]
|
||||
imports: [
|
||||
HttpModule,
|
||||
],
|
||||
providers: [
|
||||
ApplianceService,
|
||||
HttpServer,
|
||||
MockBackend,
|
||||
{ provide: XHRBackend, useExisting: MockBackend }
|
||||
]
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
// it('should be created', inject([ApplianceService], (service: ApplianceService) => {
|
||||
// expect(service).toBeTruthy();
|
||||
// }));
|
||||
it('should be created',
|
||||
inject([ApplianceService, Http, MockBackend],
|
||||
(service: ApplianceService, client: Http, backend: MockBackend) => {
|
||||
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
|
||||
it('should ask for the list from server',
|
||||
async(inject([ApplianceService, Http, MockBackend],
|
||||
(service: ApplianceService, client: Http, backend: MockBackend) => {
|
||||
|
||||
const server = new Server();
|
||||
server.ip = "127.0.0.1";
|
||||
server.port = 3080;
|
||||
server.authorization = "none";
|
||||
|
||||
service.list(server).subscribe();
|
||||
|
||||
backend.connections.subscribe((c: MockConnection) => {
|
||||
expect(c.request.url).toBe('test');
|
||||
});
|
||||
|
||||
expect(backend.verifyNoPendingRequests).toBeTruthy();
|
||||
})));
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user