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

47 lines
1.3 KiB
JavaScript

import './index';
describe('vnItemDescriptor', () => {
let controller;
let $httpBackend;
const item = {
id: 1,
itemType: {
warehouseFk: 1
}
};
const stock = {
visible: 1,
available: 5
};
beforeEach(ngModule('item'));
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
$httpBackend.whenRoute('GET', `Items/${item.id}/getVisibleAvailable`).respond(stock);
controller = $componentController('vnItemDescriptor', {$element: null});
}));
describe('loadData()', () => {
it(`should perform a get query to store the item data into the controller`, () => {
$httpBackend.expectGET(`Items/${item.id}/getCard`).respond(item);
controller.id = item.id;
$httpBackend.flush();
expect(controller.item).toEqual(item);
});
});
describe('updateStock()', () => {
it(`should perform a get query to store the item data into the controller`, () => {
$httpBackend.expectGET(`Items/${item.id}/getCard`).respond(item);
controller.id = item.id;
$httpBackend.flush();
expect(controller.item).toEqual(item);
});
});
});