43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
|
import './index.js';
|
||
|
|
||
|
describe('Item', () => {
|
||
|
describe('Component vnItemDiary', () => {
|
||
|
let $componentController;
|
||
|
let $scope;
|
||
|
let controller;
|
||
|
let $httpBackend;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
angular.mock.module('item');
|
||
|
});
|
||
|
|
||
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
||
|
$componentController = _$componentController_;
|
||
|
$httpBackend = _$httpBackend_;
|
||
|
$scope = $rootScope.$new();
|
||
|
controller = $componentController('vnItemDiary', {$scope: $scope});
|
||
|
controller.item = {id: 3};
|
||
|
}));
|
||
|
|
||
|
describe('set warehouseFk()', () => {
|
||
|
it(`should call _getItemDiary() with 2 and set warehouseFk`, () => {
|
||
|
spyOn(controller, '_getItemDiary');
|
||
|
controller.warehouseFk = 2;
|
||
|
|
||
|
expect(controller._getItemDiary).toHaveBeenCalledWith(2);
|
||
|
expect(controller.warehouseFk).toEqual(2);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('_getItemDiary()', () => {
|
||
|
it(`should make a request to get the diary hwen is called with a number`, () => {
|
||
|
$httpBackend.whenGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}').respond({data: 'item'});
|
||
|
$httpBackend.expectGET('/item/api/Items/getDiary?params={"itemFk":3,"warehouseFk":2}');
|
||
|
controller._getItemDiary(2);
|
||
|
$httpBackend.flush();
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|