salix/modules/item/front/diary/index.spec.js

46 lines
1.6 KiB
JavaScript
Raw Normal View History

import './index.js';
2018-12-27 11:54:16 +00:00
import crudModel from 'core/mocks/crud-model';
describe('Item', () => {
describe('Component vnItemDiary', () => {
let $scope;
let controller;
beforeEach(ngModule('item'));
2020-03-17 13:43:46 +00:00
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$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};
}));
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}};
2020-03-17 13:43:46 +00:00
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
$scope.$apply();
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));
$scope.$apply();
2018-09-06 13:08:02 +00:00
expect(controller.warehouseFk).toEqual(4);
expect(controller.item.id).toEqual(1);
});
});
});
});