2018-06-04 07:48:32 +00:00
|
|
|
import './index.js';
|
2018-12-27 11:54:16 +00:00
|
|
|
import crudModel from 'core/mocks/crud-model';
|
2018-06-04 07:48:32 +00:00
|
|
|
|
2018-07-31 11:49:54 +00:00
|
|
|
describe('Item', () => {
|
2018-06-04 07:48:32 +00:00
|
|
|
describe('Component vnItemDiary', () => {
|
|
|
|
let $scope;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('item'));
|
2018-06-04 07:48:32 +00:00
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
2018-06-04 07:48:32 +00:00
|
|
|
$scope = $rootScope.$new();
|
2020-03-17 13:43:46 +00:00
|
|
|
const $element = angular.element('<vn-item-diary></vn-item-diary>');
|
|
|
|
controller = $componentController('vnItemDiary', {$element, $scope});
|
|
|
|
controller.$.model = crudModel;
|
|
|
|
controller.$params = {id: 1};
|
2018-06-04 07:48:32 +00:00
|
|
|
}));
|
|
|
|
|
2018-07-04 06:50:34 +00:00
|
|
|
describe('set item()', () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
it('should set warehouseFk property based on itemType warehouseFk', () => {
|
2020-03-17 13:43:46 +00:00
|
|
|
jest.spyOn(controller.$, '$applyAsync');
|
2018-09-06 13:08:02 +00:00
|
|
|
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
2018-07-04 06:50:34 +00:00
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
2019-02-13 06:57:08 +00:00
|
|
|
$scope.$apply();
|
2018-09-18 11:34:11 +00:00
|
|
|
|
2018-09-06 13:08:02 +00:00
|
|
|
expect(controller.warehouseFk).toEqual(1);
|
|
|
|
expect(controller.item.id).toEqual(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should set warehouseFk property based on url query warehouseFk`, () => {
|
2020-03-17 13:43:46 +00:00
|
|
|
jest.spyOn(controller.$, '$applyAsync');
|
|
|
|
controller.$params.warehouseFk = 4;
|
2018-09-06 13:08:02 +00:00
|
|
|
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
|
|
|
|
2020-03-17 13:43:46 +00:00
|
|
|
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
2019-02-13 06:57:08 +00:00
|
|
|
$scope.$apply();
|
2018-09-18 11:34:11 +00:00
|
|
|
|
2018-09-06 13:08:02 +00:00
|
|
|
expect(controller.warehouseFk).toEqual(4);
|
|
|
|
expect(controller.item.id).toEqual(1);
|
2018-06-04 07:48:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|