gns3-web-ui/src/app/services/template.service.spec.ts
2019-03-07 06:17:58 -08:00

42 lines
1.3 KiB
TypeScript

import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient } from '@angular/common/http';
import { TemplateService } from './template.service';
import { Server } from '../models/server';
import { HttpServer } from './http-server.service';
import { AppTestingModule } from '../testing/app-testing/app-testing.module';
describe('TemplateService', () => {
let httpClient: HttpClient;
let httpTestingController: HttpTestingController;
let service: TemplateService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, AppTestingModule],
providers: [TemplateService, HttpServer]
});
httpClient = TestBed.get(HttpClient);
httpTestingController = TestBed.get(HttpTestingController);
service = TestBed.get(TemplateService);
});
afterEach(() => {
httpTestingController.verify();
});
it('should ask for the list from server', () => {
const server = new Server();
server.host = '127.0.0.1';
server.port = 3080;
server.authorization = 'none';
service.list(server).subscribe(() => {});
const req = httpTestingController.expectOne('http://127.0.0.1:3080/v2/templates');
expect(req.request.url).toBe('http://127.0.0.1:3080/v2/templates');
});
});