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

60 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

import './index';
describe('vnItemDescriptor', () => {
let controller;
let $httpBackend;
const item = {
id: 1,
itemType: {
warehouseFk: 1
},
isPhotoRequested: true
};
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);
});
});
2020-05-26 08:37:52 +00:00
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);
});
});
describe('onUploadResponse()', () => {
it(`should change isPhotoRequested when a new photo is uploaded`, () => {
2023-02-24 09:37:35 +00:00
controller.item = item;
controller.$rootScope = {imagePath: () => {}};
controller.$.photo = {setAttribute: () => {}};
2023-02-24 09:37:35 +00:00
$httpBackend.expectPATCH(`Items/${item.id}`).respond(200);
controller.onUploadResponse();
$httpBackend.flush();
});
});
});