2018-06-04 07:48:32 +00:00
|
|
|
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_;
|
2018-06-08 11:26:06 +00:00
|
|
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
2018-06-04 07:48:32 +00:00
|
|
|
$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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|