1 import { TestBed } from '@angular/core/testing';
2 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
4 import { VorgangService } from './vorgang.service';
6 describe('VorgangService', () => {
7 let service: VorgangService;
8 let httpMock: HttpTestingController;
11 TestBed.configureTestingModule({
12 imports: [ HttpClientTestingModule ],
13 providers: [ VorgangService ]
15 service = TestBed.inject(VorgangService);
16 httpMock = TestBed.inject(HttpTestingController);
20 // After every test, assert that there are no more pending requests.
24 it('should be created', () => {
25 expect(service).toBeTruthy();
28 describe('#getUrlSave', () => {
29 it ('should reate valid url for save', () => {
30 const expectedUrl = 'http://localhost:1991/las/VBID/save';
32 expect(service.getUrlSave('VBID')).toBe(expectedUrl);
36 describe('#create', () => {
37 it('should return Vorgang', () => {
38 const expectedVorgang = require('../mock/vorgang.json');
40 service.create({ type: null, vbId: 'greetings', vorgangId: '1' , zustand: 'Hello world!'}).subscribe(
41 vorgang => expect(vorgang).toEqual(expectedVorgang),
45 const req = httpMock.expectOne(service.getUrlSave(expectedVorgang.vbId));
46 expect(req.request.method).toBe('POST');
47 req.flush(expectedVorgang);