73 lines
2.6 KiB
JavaScript
73 lines
2.6 KiB
JavaScript
import './index';
|
|
|
|
describe('Worker', () => {
|
|
describe('Component vnWorkerPda', () => {
|
|
let $httpBackend;
|
|
let $scope;
|
|
let $element;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('worker'));
|
|
|
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
$scope = $rootScope.$new();
|
|
$element = angular.element('<vn-worker-pda></vn-worker-pda>');
|
|
controller = $componentController('vnWorkerPda', {$element, $scope});
|
|
$httpBackend.expectGET(`DeviceProductionUsers`).respond();
|
|
}));
|
|
|
|
describe('deallocatePDA()', () => {
|
|
it('should make an HTTP Post query to deallocatePDA', () => {
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
controller.currentPDA = {deviceProductionFk: 1};
|
|
controller.$params.id = 1;
|
|
|
|
$httpBackend
|
|
.expectPOST(`Workers/${controller.$params.id}/deallocatePDA`,
|
|
{pda: controller.currentPDA.deviceProductionFk})
|
|
.respond();
|
|
controller.deallocatePDA();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
expect(controller.currentPDA).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('allocatePDA()', () => {
|
|
it('should make an HTTP Post query to allocatePDA', () => {
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
controller.newPDA = 4;
|
|
controller.$params.id = 1;
|
|
|
|
$httpBackend
|
|
.expectPOST(`Workers/${controller.$params.id}/allocatePDA`,
|
|
{pda: controller.newPDA})
|
|
.respond();
|
|
controller.allocatePDA();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
expect(controller.newPDA).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('setCurrentPDA()', () => {
|
|
it('should set CurrentPDA', () => {
|
|
const data = {
|
|
deviceProductionFk: 1,
|
|
deviceProduction: {
|
|
modelFk: 1,
|
|
serialNumber: 1
|
|
}
|
|
};
|
|
controller.setCurrentPDA(data);
|
|
|
|
expect(controller.currentPDA).toBeDefined();
|
|
expect(controller.currentPDA.description).toBeDefined();
|
|
});
|
|
});
|
|
});
|
|
});
|