Skip to content

Commit

Permalink
Add ItemService.createItem() Test
Browse files Browse the repository at this point in the history
  • Loading branch information
helkv committed Jun 5, 2023
1 parent 1b53f54 commit b3bb6b2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/app/core/services/impl/item.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TestBed } from '@angular/core/testing';
import { ItemService } from './item.service';
import { PropertiesService } from '../properties.service';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {ItemVersionVO} from "../../model/model";

describe('ItemService', () => {
let itemService: ItemService;
Expand All @@ -26,11 +27,24 @@ describe('ItemService', () => {
controller = TestBed.inject(HttpTestingController);
});

it('should be created', () => {
expect(itemService).toBeTruthy();
it('#createItem should send a correct HTTP-Request', () => {
const item = <ItemVersionVO>{
message : 'testMessage'
};
const token = 'token';
const expectedRequestUrl = mockedIngeRestUri + '/items';

itemService.createItem(item, token).subscribe();

const request = controller.expectOne(expectedRequestUrl);
expect(request.request.method).toEqual('POST');
expect(request.request.headers.get('Authorization')).toEqual('token');
expect(request.request.headers.get('Content-Type')).toEqual('application/json');
expect(request.request.body).toEqual('{"message":"testMessage"}');
controller.verify();
});

it('getItem request', () => {
it('#getItem should send a correct HTTP-Request', () => {
const itemId = '1';
const expectedRequestUrl = mockedIngeRestUri + '/items/' + itemId;

Expand Down

0 comments on commit b3bb6b2

Please sign in to comment.