test fixed

This commit is contained in:
Gerard 2019-01-14 14:59:14 +01:00
parent bac033a6b8
commit 8d0366e7bf
1 changed files with 13 additions and 16 deletions

View File

@ -1,6 +1,6 @@
import './index.js';
describe('Order', () => {
fdescribe('Order', () => {
describe('Component vnOrderLine', () => {
let $state;
let controller;
@ -17,6 +17,7 @@ describe('Order', () => {
controller.$scope.popover = {relocate: () => {}};
controller.$scope.descriptor = {show: () => {}};
controller.vnApp = {showSuccess: () => {}};
controller.card = {reload: () => {}};
}));
describe('getRows()', () => {
@ -44,12 +45,19 @@ describe('Order', () => {
});
});
describe('removeRow()', () => {
it('should remove a row from rows and add his id to idsRemoved', () => {
controller.removeRow(0);
describe('deleteRow()', () => {
it('should remove a row from rows and add save the data if the response is ACCEPT', () => {
expect(controller.rows.length).toBe(1);
spyOn(controller.vnApp, 'showSuccess');
spyOn(controller, 'getVAT');
controller.deleteRow('ACCEPT');
$httpBackend.expectPOST(`/order/api/OrderRows/removes`).respond();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
expect(controller.rows.length).toBe(0);
expect(controller.idsToRemove[0]).toBe(1);
expect(controller.idsToRemove).toBe(undefined);
});
});
@ -74,16 +82,5 @@ describe('Order', () => {
expect(controller.$scope.popover.relocate).toHaveBeenCalledWith();
});
});
describe('save()', () => {
it('should make a query to remove the selected rows and call vnApp.showSuccess', () => {
spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectPOST(`/order/api/OrderRows/removes`).respond();
controller.save();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
});
});
});
});