Merge branch '2131_jest_spyOn' of verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
21ace6ef4e
|
@ -16,7 +16,7 @@ describe('Component vnButtonMenu', () => {
|
||||||
|
|
||||||
describe('onButtonClick(event)', () => {
|
describe('onButtonClick(event)', () => {
|
||||||
it(`should emit the open event`, () => {
|
it(`should emit the open event`, () => {
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
|
|
||||||
let event = new MouseEvent('click', {
|
let event = new MouseEvent('click', {
|
||||||
view: controller.element.window,
|
view: controller.element.window,
|
||||||
|
@ -31,7 +31,7 @@ describe('Component vnButtonMenu', () => {
|
||||||
|
|
||||||
describe('onDropDownSelect(value)', () => {
|
describe('onDropDownSelect(value)', () => {
|
||||||
it(`should set field to the given value and emit the change event`, () => {
|
it(`should set field to the given value and emit the change event`, () => {
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
controller.onDropDownSelect({name: 'Item name'});
|
controller.onDropDownSelect({name: 'Item name'});
|
||||||
|
|
||||||
expect(controller.field).toBe('Item name');
|
expect(controller.field).toBe('Item name');
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Component vnCalendar', () => {
|
||||||
|
|
||||||
describe('moveNext()', () => {
|
describe('moveNext()', () => {
|
||||||
it(`should shift to the next month, then emit a 'move' event`, () => {
|
it(`should shift to the next month, then emit a 'move' event`, () => {
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
let nextMonth = new Date(date.getTime());
|
let nextMonth = new Date(date.getTime());
|
||||||
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
nextMonth.setMonth(nextMonth.getMonth() + 1);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ describe('Component vnCalendar', () => {
|
||||||
|
|
||||||
describe('movePrevious()', () => {
|
describe('movePrevious()', () => {
|
||||||
it(`should shift to the previous month, then emit a 'move' event`, () => {
|
it(`should shift to the previous month, then emit a 'move' event`, () => {
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
let previousMonth = new Date(date.getTime());
|
let previousMonth = new Date(date.getTime());
|
||||||
previousMonth.setMonth(previousMonth.getMonth() - 1);
|
previousMonth.setMonth(previousMonth.getMonth() - 1);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ describe('Component vnCalendar', () => {
|
||||||
|
|
||||||
describe('select()', () => {
|
describe('select()', () => {
|
||||||
it(`should return the selected element, then emit a 'selection' event`, () => {
|
it(`should return the selected element, then emit a 'selection' event`, () => {
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
|
|
||||||
const day = new Date();
|
const day = new Date();
|
||||||
day.setHours(0, 0, 0, 0);
|
day.setHours(0, 0, 0, 0);
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe('Component vnChip', () => {
|
||||||
describe('onRemove()', () => {
|
describe('onRemove()', () => {
|
||||||
it(`should emit remove event`, () => {
|
it(`should emit remove event`, () => {
|
||||||
controller.emit = () => {};
|
controller.emit = () => {};
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
controller.onRemove();
|
controller.onRemove();
|
||||||
|
|
||||||
expect(controller.emit).toHaveBeenCalledWith('remove');
|
expect(controller.emit).toHaveBeenCalledWith('remove');
|
||||||
|
|
|
@ -25,8 +25,8 @@ describe('Component vnCrudModel', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('save()', () => {
|
describe('save()', () => {
|
||||||
it('should make an HTTP post query and then update the original rows with the returned values', () => {
|
it(`should make an HTTP post query and then update the original rows with the returned values`, () => {
|
||||||
spyOn(controller, 'applyChanges');
|
jest.spyOn(controller, 'applyChanges');
|
||||||
|
|
||||||
controller.insert({value: 'My new item 1'});
|
controller.insert({value: 'My new item 1'});
|
||||||
controller.insert({value: 'My new item 2'});
|
controller.insert({value: 'My new item 2'});
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe('Component vnDialog', () => {
|
||||||
|
|
||||||
it(`should not hide the dialog when false is returned from response handler`, () => {
|
it(`should not hide the dialog when false is returned from response handler`, () => {
|
||||||
controller.show(() => false);
|
controller.show(() => false);
|
||||||
spyOn(controller, 'hide');
|
jest.spyOn(controller, 'hide');
|
||||||
controller.respond('answer');
|
controller.respond('answer');
|
||||||
|
|
||||||
expect(controller.hide).not.toHaveBeenCalled();
|
expect(controller.hide).not.toHaveBeenCalled();
|
||||||
|
@ -51,7 +51,7 @@ describe('Component vnDialog', () => {
|
||||||
describe('respond()', () => {
|
describe('respond()', () => {
|
||||||
it(`should do nothing if dialog is already hidden`, () => {
|
it(`should do nothing if dialog is already hidden`, () => {
|
||||||
controller.onResponse = () => {};
|
controller.onResponse = () => {};
|
||||||
spyOn(controller, 'onResponse');
|
jest.spyOn(controller, 'onResponse');
|
||||||
controller.respond();
|
controller.respond();
|
||||||
|
|
||||||
expect(controller.onResponse).not.toHaveBeenCalledWith();
|
expect(controller.onResponse).not.toHaveBeenCalledWith();
|
||||||
|
@ -59,7 +59,7 @@ describe('Component vnDialog', () => {
|
||||||
|
|
||||||
it(`should call onResponse() if it's defined`, () => {
|
it(`should call onResponse() if it's defined`, () => {
|
||||||
controller.onResponse = () => {};
|
controller.onResponse = () => {};
|
||||||
spyOn(controller, 'onResponse');
|
jest.spyOn(controller, 'onResponse');
|
||||||
|
|
||||||
controller.show();
|
controller.show();
|
||||||
controller.respond();
|
controller.respond();
|
||||||
|
@ -69,7 +69,7 @@ describe('Component vnDialog', () => {
|
||||||
|
|
||||||
it(`should call onResponse() with the response`, () => {
|
it(`should call onResponse() with the response`, () => {
|
||||||
controller.onResponse = () => {};
|
controller.onResponse = () => {};
|
||||||
spyOn(controller, 'onResponse');
|
jest.spyOn(controller, 'onResponse');
|
||||||
|
|
||||||
controller.show();
|
controller.show();
|
||||||
controller.respond('response');
|
controller.respond('response');
|
||||||
|
@ -79,7 +79,7 @@ describe('Component vnDialog', () => {
|
||||||
|
|
||||||
it(`should call onAccept() when accept response is given`, () => {
|
it(`should call onAccept() when accept response is given`, () => {
|
||||||
controller.onAccept = () => {};
|
controller.onAccept = () => {};
|
||||||
spyOn(controller, 'onAccept');
|
jest.spyOn(controller, 'onAccept');
|
||||||
|
|
||||||
controller.show();
|
controller.show();
|
||||||
controller.respond('accept');
|
controller.respond('accept');
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Component vnMultiCheck', () => {
|
||||||
|
|
||||||
describe('checked() setter', () => {
|
describe('checked() setter', () => {
|
||||||
it(`should set controller _checked property with the argument received then call toggle()`, () => {
|
it(`should set controller _checked property with the argument received then call toggle()`, () => {
|
||||||
spyOn(controller, 'toggle');
|
jest.spyOn(controller, 'toggle');
|
||||||
controller.checked = crudModel;
|
controller.checked = crudModel;
|
||||||
|
|
||||||
expect(controller._checked).toEqual(crudModel);
|
expect(controller._checked).toEqual(crudModel);
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('Component vnPopover', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should enable the shown property and emit the open event`, () => {
|
it(`should enable the shown property and emit the open event`, () => {
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.shown).toBeTruthy();
|
expect(controller.shown).toBeTruthy();
|
||||||
|
@ -31,13 +31,13 @@ describe('Component vnPopover', () => {
|
||||||
|
|
||||||
it(`should do nothing if it's already shown`, () => {
|
it(`should do nothing if it's already shown`, () => {
|
||||||
controller.shown = true;
|
controller.shown = true;
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.emit).not.toHaveBeenCalledWith('open');
|
expect(controller.emit).not.toHaveBeenCalledWith('open');
|
||||||
});
|
});
|
||||||
|
|
||||||
//#1615 migrar karma a jest (this doesn't work anymore, needs fixing)
|
// #1615 migrar karma a jest (this doesn't work anymore, needs fixing)
|
||||||
xit(`should check that popover is visible into the screen`, () => {
|
xit(`should check that popover is visible into the screen`, () => {
|
||||||
$parent.css({
|
$parent.css({
|
||||||
backgroundColor: 'red',
|
backgroundColor: 'red',
|
||||||
|
@ -65,7 +65,7 @@ describe('Component vnPopover', () => {
|
||||||
describe('hide()', () => {
|
describe('hide()', () => {
|
||||||
it(`should disable the shown property and emit the close event`, inject($timeout => {
|
it(`should disable the shown property and emit the close event`, inject($timeout => {
|
||||||
controller.show();
|
controller.show();
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
controller.hide();
|
controller.hide();
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ describe('Component vnPopover', () => {
|
||||||
|
|
||||||
it(`should do nothing if it's already hidden`, () => {
|
it(`should do nothing if it's already hidden`, () => {
|
||||||
controller.shown = false;
|
controller.shown = false;
|
||||||
spyOn(controller, 'emit');
|
jest.spyOn(controller, 'emit');
|
||||||
controller.hide();
|
controller.hide();
|
||||||
|
|
||||||
expect(controller.emit).not.toHaveBeenCalledWith('close');
|
expect(controller.emit).not.toHaveBeenCalledWith('close');
|
||||||
|
|
|
@ -139,7 +139,7 @@ describe('Component vnSearchbar', () => {
|
||||||
|
|
||||||
describe('doSearch()', () => {
|
describe('doSearch()', () => {
|
||||||
it(`should go to the search state and pass the filter as query param`, () => {
|
it(`should go to the search state and pass the filter as query param`, () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
controller.searchState = 'search.state';
|
controller.searchState = 'search.state';
|
||||||
controller.doSearch(filter);
|
controller.doSearch(filter);
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,14 @@ describe('Component vnSpinner', () => {
|
||||||
|
|
||||||
describe('enable()', () => {
|
describe('enable()', () => {
|
||||||
it(`should call start() when enable is set to true`, () => {
|
it(`should call start() when enable is set to true`, () => {
|
||||||
spyOn(controller, 'start');
|
jest.spyOn(controller, 'start');
|
||||||
controller.enable = true;
|
controller.enable = true;
|
||||||
|
|
||||||
expect(controller.start).toHaveBeenCalledWith();
|
expect(controller.start).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should call stop() when enable is set to false`, () => {
|
it(`should call stop() when enable is set to false`, () => {
|
||||||
spyOn(controller, 'stop');
|
jest.spyOn(controller, 'stop');
|
||||||
controller.enable = false;
|
controller.enable = false;
|
||||||
|
|
||||||
expect(controller.stop).toHaveBeenCalledWith();
|
expect(controller.stop).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe('Component vnStepControl', () => {
|
||||||
|
|
||||||
beforeEach(angular.mock.inject(($componentController, _$state_) => {
|
beforeEach(angular.mock.inject(($componentController, _$state_) => {
|
||||||
$state = _$state_;
|
$state = _$state_;
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
controller = $componentController('vnStepControl', {$state: $state});
|
controller = $componentController('vnStepControl', {$state: $state});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Component vnTh', () => {
|
||||||
describe('onInit()', () => {
|
describe('onInit()', () => {
|
||||||
it(`should define controllers order as per defaultOrder then call setOrder()`, () => {
|
it(`should define controllers order as per defaultOrder then call setOrder()`, () => {
|
||||||
controller.defaultOrder = 'DESC';
|
controller.defaultOrder = 'DESC';
|
||||||
spyOn(controller.table, 'setOrder');
|
jest.spyOn(controller.table, 'setOrder');
|
||||||
controller.$onInit();
|
controller.$onInit();
|
||||||
|
|
||||||
expect(controller.order).toEqual('DESC');
|
expect(controller.order).toEqual('DESC');
|
||||||
|
@ -44,7 +44,7 @@ describe('Component vnTh', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should call the setOrder() function after changing a value`, () => {
|
it(`should call the setOrder() function after changing a value`, () => {
|
||||||
spyOn(controller.table, 'setOrder');
|
jest.spyOn(controller.table, 'setOrder');
|
||||||
controller.order = 'Change me!';
|
controller.order = 'Change me!';
|
||||||
|
|
||||||
expect(controller.table.setOrder).toHaveBeenCalledWith('MyField', 'Change me!');
|
expect(controller.table.setOrder).toHaveBeenCalledWith('MyField', 'Change me!');
|
||||||
|
@ -54,7 +54,7 @@ describe('Component vnTh', () => {
|
||||||
describe('onToggleOrder()', () => {
|
describe('onToggleOrder()', () => {
|
||||||
it(`should not call updateArrow() method if field property isn't defined`, () => {
|
it(`should not call updateArrow() method if field property isn't defined`, () => {
|
||||||
controller.column.setAttribute('field', '');
|
controller.column.setAttribute('field', '');
|
||||||
spyOn(controller, 'updateArrow');
|
jest.spyOn(controller, 'updateArrow');
|
||||||
|
|
||||||
controller.onToggleOrder();
|
controller.onToggleOrder();
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ describe('Component vnTh', () => {
|
||||||
it(`should call toggleOrder() method if field property and
|
it(`should call toggleOrder() method if field property and
|
||||||
table field property equals and then call updateArrow()`, () => {
|
table field property equals and then call updateArrow()`, () => {
|
||||||
controller.table.field = 'MyField';
|
controller.table.field = 'MyField';
|
||||||
spyOn(controller, 'toggleOrder');
|
jest.spyOn(controller, 'toggleOrder');
|
||||||
spyOn(controller, 'updateArrow');
|
jest.spyOn(controller, 'updateArrow');
|
||||||
|
|
||||||
controller.onToggleOrder();
|
controller.onToggleOrder();
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ describe('Component vnTh', () => {
|
||||||
it(`should call setOrder() method if field property and
|
it(`should call setOrder() method if field property and
|
||||||
table field property doesn't equals and then call updateArrow()`, () => {
|
table field property doesn't equals and then call updateArrow()`, () => {
|
||||||
controller.table.field = 'MyField2';
|
controller.table.field = 'MyField2';
|
||||||
spyOn(controller.table, 'setOrder');
|
jest.spyOn(controller.table, 'setOrder');
|
||||||
spyOn(controller, 'updateArrow');
|
jest.spyOn(controller, 'updateArrow');
|
||||||
|
|
||||||
controller.onToggleOrder();
|
controller.onToggleOrder();
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('Component vnTreeview', () => {
|
||||||
xdescribe('undrop()', () => {
|
xdescribe('undrop()', () => {
|
||||||
it(`should reset all drop events and properties`, () => {
|
it(`should reset all drop events and properties`, () => {
|
||||||
controller.dropping = angular.element(`<vn-treeview-child class="dropping"></vn-treeview-child>`);
|
controller.dropping = angular.element(`<vn-treeview-child class="dropping"></vn-treeview-child>`);
|
||||||
spyOn(controller.dropping.classList, 'remove');
|
jest.spyOn(controller.dropping.classList, 'remove');
|
||||||
|
|
||||||
controller.undrop();
|
controller.undrop();
|
||||||
|
|
||||||
|
@ -69,9 +69,7 @@ describe('Component vnTreeview', () => {
|
||||||
|
|
||||||
describe('fetch()', () => {
|
describe('fetch()', () => {
|
||||||
it(`should call the fetchFunc() method`, () => {
|
it(`should call the fetchFunc() method`, () => {
|
||||||
spyOn(controller, 'fetchFunc').and.returnValue(
|
jest.spyOn(controller, 'fetchFunc');
|
||||||
new Promise(resolve => resolve([{name: 'My item'}]))
|
|
||||||
);
|
|
||||||
controller.fetch().then(() => {
|
controller.fetch().then(() => {
|
||||||
expect(controller.data).toBeDefined();
|
expect(controller.data).toBeDefined();
|
||||||
});
|
});
|
||||||
|
@ -82,7 +80,7 @@ describe('Component vnTreeview', () => {
|
||||||
|
|
||||||
describe('setParent()', () => {
|
describe('setParent()', () => {
|
||||||
it(`should set the parent property recursively to each element of an item list`, () => {
|
it(`should set the parent property recursively to each element of an item list`, () => {
|
||||||
spyOn(controller, 'setParent').and.callThrough();
|
jest.spyOn(controller, 'setParent');
|
||||||
const items = [{name: 'Item1'}, {name: 'Item2', childs: [
|
const items = [{name: 'Item1'}, {name: 'Item2', childs: [
|
||||||
{name: 'Item3'}
|
{name: 'Item3'}
|
||||||
]}];
|
]}];
|
||||||
|
@ -97,8 +95,8 @@ describe('Component vnTreeview', () => {
|
||||||
|
|
||||||
describe('onToggle()', () => {
|
describe('onToggle()', () => {
|
||||||
it(`should call the fold() or unfold() methods`, () => {
|
it(`should call the fold() or unfold() methods`, () => {
|
||||||
spyOn(controller, 'fold');
|
jest.spyOn(controller, 'fold');
|
||||||
spyOn(controller, 'unfold');
|
jest.spyOn(controller, 'unfold');
|
||||||
|
|
||||||
let event = new MouseEvent('click', {
|
let event = new MouseEvent('click', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
@ -130,11 +128,9 @@ describe('Component vnTreeview', () => {
|
||||||
describe('unfold()', () => {
|
describe('unfold()', () => {
|
||||||
it(`should unfold a parent item`, () => {
|
it(`should unfold a parent item`, () => {
|
||||||
const expectedResponse = [{name: 'Item 1'}, {name: 'Item 2'}];
|
const expectedResponse = [{name: 'Item 1'}, {name: 'Item 2'}];
|
||||||
spyOn(controller, 'fetchFunc').and.returnValue(
|
jest.spyOn(controller, 'fetchFunc');
|
||||||
new Promise(resolve => resolve(expectedResponse))
|
jest.spyOn(controller, 'setParent');
|
||||||
);
|
jest.spyOn(controller, 'sortFunc');
|
||||||
spyOn(controller, 'setParent');
|
|
||||||
spyOn(controller, 'sortFunc');
|
|
||||||
const parent = {name: 'My item', sons: 1};
|
const parent = {name: 'My item', sons: 1};
|
||||||
const child = {name: 'Item 1'};
|
const child = {name: 'Item 1'};
|
||||||
child.parent = parent;
|
child.parent = parent;
|
||||||
|
@ -157,7 +153,7 @@ describe('Component vnTreeview', () => {
|
||||||
view: window
|
view: window
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(controller, 'removeFunc');
|
jest.spyOn(controller, 'removeFunc');
|
||||||
const item = {name: 'My item'};
|
const item = {name: 'My item'};
|
||||||
controller.onRemove(event, item);
|
controller.onRemove(event, item);
|
||||||
|
|
||||||
|
@ -187,7 +183,7 @@ describe('Component vnTreeview', () => {
|
||||||
view: window
|
view: window
|
||||||
});
|
});
|
||||||
|
|
||||||
spyOn(controller, 'createFunc');
|
jest.spyOn(controller, 'createFunc');
|
||||||
const parent = {name: 'My item'};
|
const parent = {name: 'My item'};
|
||||||
controller.onCreate(event, parent);
|
controller.onCreate(event, parent);
|
||||||
|
|
||||||
|
@ -197,8 +193,8 @@ describe('Component vnTreeview', () => {
|
||||||
|
|
||||||
describe('create()', () => {
|
describe('create()', () => {
|
||||||
it(`should unfold an inactive parent and then create a child`, () => {
|
it(`should unfold an inactive parent and then create a child`, () => {
|
||||||
spyOn(controller, 'unfold');
|
jest.spyOn(controller, 'unfold');
|
||||||
spyOn(controller, 'sortFunc');
|
jest.spyOn(controller, 'sortFunc');
|
||||||
const parent = {name: 'My item', sons: 2, childs: [
|
const parent = {name: 'My item', sons: 2, childs: [
|
||||||
{name: 'Item 1'},
|
{name: 'Item 1'},
|
||||||
{name: 'Item 2'}
|
{name: 'Item 2'}
|
||||||
|
@ -216,8 +212,8 @@ describe('Component vnTreeview', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should create a child on an active parent`, () => {
|
it(`should create a child on an active parent`, () => {
|
||||||
spyOn(controller, 'unfold');
|
jest.spyOn(controller, 'unfold');
|
||||||
spyOn(controller, 'sortFunc');
|
jest.spyOn(controller, 'sortFunc');
|
||||||
const parent = {name: 'My item', sons: 2, childs: [
|
const parent = {name: 'My item', sons: 2, childs: [
|
||||||
{name: 'Item 1'},
|
{name: 'Item 1'},
|
||||||
{name: 'Item 2'}
|
{name: 'Item 2'}
|
||||||
|
@ -236,9 +232,7 @@ describe('Component vnTreeview', () => {
|
||||||
|
|
||||||
describe('move()', () => {
|
describe('move()', () => {
|
||||||
it(`should move an item to anocher parent and then unfold the parent`, () => {
|
it(`should move an item to anocher parent and then unfold the parent`, () => {
|
||||||
spyOn(controller, 'unfold').and.returnValue(
|
jest.spyOn(controller, 'unfold');
|
||||||
new Promise(resolve => resolve())
|
|
||||||
);
|
|
||||||
const newParent = {name: 'My item 2', sons: 0};
|
const newParent = {name: 'My item 2', sons: 0};
|
||||||
const parent = {name: 'My item', sons: 3, childs: [
|
const parent = {name: 'My item', sons: 3, childs: [
|
||||||
{name: 'Item 1'},
|
{name: 'Item 1'},
|
||||||
|
@ -255,8 +249,8 @@ describe('Component vnTreeview', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should move an item to anocher parent`, () => {
|
it(`should move an item to anocher parent`, () => {
|
||||||
spyOn(controller, 'unfold');
|
jest.spyOn(controller, 'unfold');
|
||||||
spyOn(controller, 'create');
|
jest.spyOn(controller, 'create');
|
||||||
const newParent = {name: 'My item 2', sons: 0, active: true};
|
const newParent = {name: 'My item 2', sons: 0, active: true};
|
||||||
const parent = {name: 'My item', sons: 3, childs: [
|
const parent = {name: 'My item', sons: 3, childs: [
|
||||||
{name: 'Item 1'},
|
{name: 'Item 1'},
|
||||||
|
|
|
@ -25,10 +25,10 @@ describe('Component vnWatcher', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('$onInit()', () => {
|
describe('$onInit()', () => {
|
||||||
it(`should call fetchData() if controllers get and url properties are defined`, () => {
|
it('should call fetchData() if controllers get and url properties are defined', () => {
|
||||||
controller.get = () => {};
|
controller.get = () => {};
|
||||||
controller.url = 'test.com';
|
controller.url = 'test.com';
|
||||||
spyOn(controller, 'fetchData');
|
jest.spyOn(controller, 'fetchData').mockReturnThis();
|
||||||
controller.$onInit();
|
controller.$onInit();
|
||||||
|
|
||||||
expect(controller.fetchData).toHaveBeenCalledWith();
|
expect(controller.fetchData).toHaveBeenCalledWith();
|
||||||
|
@ -45,7 +45,7 @@ describe('Component vnWatcher', () => {
|
||||||
|
|
||||||
describe('fetchData()', () => {
|
describe('fetchData()', () => {
|
||||||
it(`should perform a query then store the received data into controller.data and call updateOriginalData()`, () => {
|
it(`should perform a query then store the received data into controller.data and call updateOriginalData()`, () => {
|
||||||
spyOn(controller, 'updateOriginalData');
|
jest.spyOn(controller, 'updateOriginalData');
|
||||||
let json = {data: 'some data'};
|
let json = {data: 'some data'};
|
||||||
controller.data = [1];
|
controller.data = [1];
|
||||||
controller.idField = 0;
|
controller.idField = 0;
|
||||||
|
@ -61,9 +61,9 @@ describe('Component vnWatcher', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('submitBack()', () => {
|
describe('submitBack()', () => {
|
||||||
it(`should call controller.window.history.back() function after calling controllers submit() function`, done => {
|
it('should call controller.window.history.back() function after calling controllers submit() function', done => {
|
||||||
spyOn(controller, 'submit').and.returnValue(Promise.resolve());
|
jest.spyOn(controller, 'submit').mockReturnValue(Promise.resolve());
|
||||||
spyOn(controller.window.history, 'back');
|
jest.spyOn(controller.window.history, 'back');
|
||||||
controller.submitBack()
|
controller.submitBack()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
expect(controller.submit).toHaveBeenCalledWith();
|
expect(controller.submit).toHaveBeenCalledWith();
|
||||||
|
@ -74,9 +74,9 @@ describe('Component vnWatcher', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('submitGo()', () => {
|
describe('submitGo()', () => {
|
||||||
it(`should call controller.$state.go() function after calling controllers submit() function`, done => {
|
it('should call controller.$state.go() function after calling controllers submit() function', done => {
|
||||||
spyOn(controller, 'submit').and.returnValue(Promise.resolve());
|
jest.spyOn(controller, 'submit').mockReturnValue(Promise.resolve());
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
let state = 'the.State';
|
let state = 'the.State';
|
||||||
controller.submitGo(state)
|
controller.submitGo(state)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -112,7 +112,7 @@ describe('Component vnWatcher', () => {
|
||||||
$setSubmitted: () => {},
|
$setSubmitted: () => {},
|
||||||
$setPristine: () => {}
|
$setPristine: () => {}
|
||||||
};
|
};
|
||||||
spyOn(controller.form, '$setSubmitted');
|
jest.spyOn(controller.form, '$setSubmitted');
|
||||||
controller.realSubmit();
|
controller.realSubmit();
|
||||||
|
|
||||||
expect(controller.form.$setSubmitted).toHaveBeenCalledWith();
|
expect(controller.form.$setSubmitted).toHaveBeenCalledWith();
|
||||||
|
@ -141,7 +141,7 @@ describe('Component vnWatcher', () => {
|
||||||
controller.idField = 'id';
|
controller.idField = 'id';
|
||||||
controller.url = 'test.com';
|
controller.url = 'test.com';
|
||||||
let json = {data: 'some data'};
|
let json = {data: 'some data'};
|
||||||
spyOn(controller, 'writeData').and.callThrough();
|
jest.spyOn(controller, 'writeData');
|
||||||
$httpBackend.whenPATCH(`${controller.url}/1`, changedData).respond(json);
|
$httpBackend.whenPATCH(`${controller.url}/1`, changedData).respond(json);
|
||||||
$httpBackend.expectPATCH(`${controller.url}/1`);
|
$httpBackend.expectPATCH(`${controller.url}/1`);
|
||||||
controller.realSubmit()
|
controller.realSubmit()
|
||||||
|
@ -161,7 +161,7 @@ describe('Component vnWatcher', () => {
|
||||||
controller.orgData = {id: 1};
|
controller.orgData = {id: 1};
|
||||||
controller.url = 'test.com';
|
controller.url = 'test.com';
|
||||||
let json = {data: 'some data'};
|
let json = {data: 'some data'};
|
||||||
spyOn(controller, 'writeData').and.callThrough();
|
jest.spyOn(controller, 'writeData');
|
||||||
$httpBackend.whenPOST(`${controller.url}`, controller.data).respond(json);
|
$httpBackend.whenPOST(`${controller.url}`, controller.data).respond(json);
|
||||||
$httpBackend.expectPOST(`${controller.url}`, controller.data);
|
$httpBackend.expectPOST(`${controller.url}`, controller.data);
|
||||||
controller.realSubmit()
|
controller.realSubmit()
|
||||||
|
@ -175,7 +175,7 @@ describe('Component vnWatcher', () => {
|
||||||
|
|
||||||
describe('writeData()', () => {
|
describe('writeData()', () => {
|
||||||
it(`should call Object.asssign() function over controllers.data with json.data, then call updateOriginalData function and finally call resolve() function`, () => {
|
it(`should call Object.asssign() function over controllers.data with json.data, then call updateOriginalData function and finally call resolve() function`, () => {
|
||||||
spyOn(controller, 'updateOriginalData');
|
jest.spyOn(controller, 'updateOriginalData');
|
||||||
controller.data = {};
|
controller.data = {};
|
||||||
let json = {data: 'some data'};
|
let json = {data: 'some data'};
|
||||||
let resolve = jasmine.createSpy('resolve');
|
let resolve = jasmine.createSpy('resolve');
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe('Directive dialog', () => {
|
||||||
|
|
||||||
it('should call show() function if dialog is a instance of vnDialog', () => {
|
it('should call show() function if dialog is a instance of vnDialog', () => {
|
||||||
let html = `<div vn-dialog="myDialog"></div>`;
|
let html = `<div vn-dialog="myDialog"></div>`;
|
||||||
spyOn(controller, 'show');
|
jest.spyOn(controller, 'show');
|
||||||
compile(html);
|
compile(html);
|
||||||
element[0].click();
|
element[0].click();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe('Component vnLeftMenu', () => {
|
||||||
|
|
||||||
describe('depth() setter', () => {
|
describe('depth() setter', () => {
|
||||||
it(`should set depth property and call activateItem()`, () => {
|
it(`should set depth property and call activateItem()`, () => {
|
||||||
spyOn(controller, 'activateItem');
|
jest.spyOn(controller, 'activateItem');
|
||||||
controller.depth = 3;
|
controller.depth = 3;
|
||||||
|
|
||||||
expect(controller.depth).toEqual(3);
|
expect(controller.depth).toEqual(3);
|
||||||
|
|
|
@ -36,8 +36,8 @@ describe('claim', () => {
|
||||||
describe('openAddSalesDialog()', () => {
|
describe('openAddSalesDialog()', () => {
|
||||||
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
||||||
controller.$ = {addSales: {show: () => {}}};
|
controller.$ = {addSales: {show: () => {}}};
|
||||||
spyOn(controller, 'getClaimedSales');
|
jest.spyOn(controller, 'getClaimedSales');
|
||||||
spyOn(controller.$.addSales, 'show');
|
jest.spyOn(controller.$.addSales, 'show');
|
||||||
controller.openAddSalesDialog();
|
controller.openAddSalesDialog();
|
||||||
|
|
||||||
expect(controller.getClaimedSales).toHaveBeenCalledWith();
|
expect(controller.getClaimedSales).toHaveBeenCalledWith();
|
||||||
|
@ -58,9 +58,9 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('addClaimedSale(saleFk)', () => {
|
describe('addClaimedSale(saleFk)', () => {
|
||||||
it('should make a post and call refresh, hide and showSuccess', () => {
|
it('should make a post and call refresh, hide and showSuccess', () => {
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
spyOn(controller.$.addSales, 'hide');
|
jest.spyOn(controller.$.addSales, 'hide');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
$httpBackend.expectPOST(`ClaimEnds/`).respond({});
|
$httpBackend.expectPOST(`ClaimEnds/`).respond({});
|
||||||
controller.addClaimedSale(1);
|
controller.addClaimedSale(1);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -73,8 +73,8 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('deleteClaimedSale(id)', () => {
|
describe('deleteClaimedSale(id)', () => {
|
||||||
it('should make a delete and call refresh and showSuccess', () => {
|
it('should make a delete and call refresh and showSuccess', () => {
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
$httpBackend.expectDELETE(`ClaimEnds/1`).respond({});
|
$httpBackend.expectDELETE(`ClaimEnds/1`).respond({});
|
||||||
controller.deleteClaimedSale(1);
|
controller.deleteClaimedSale(1);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -99,8 +99,8 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('importToNewRefundTicket()', () => {
|
describe('importToNewRefundTicket()', () => {
|
||||||
it('should perform a post query and add lines from a new ticket', () => {
|
it('should perform a post query and add lines from a new ticket', () => {
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
$httpBackend.expect('POST', `ClaimBeginnings/1/importToNewRefundTicket`).respond({});
|
$httpBackend.expect('POST', `ClaimBeginnings/1/importToNewRefundTicket`).respond({});
|
||||||
controller.importToNewRefundTicket();
|
controller.importToNewRefundTicket();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -112,8 +112,8 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('showLastTickets()', () => {
|
describe('showLastTickets()', () => {
|
||||||
it('should get a list of tickets and call lastTicketsPopover show() method', () => {
|
it('should get a list of tickets and call lastTicketsPopover show() method', () => {
|
||||||
spyOn(controller.$.lastTicketsModel, 'refresh');
|
jest.spyOn(controller.$.lastTicketsModel, 'refresh');
|
||||||
spyOn(controller.$.lastTicketsPopover, 'show');
|
jest.spyOn(controller.$.lastTicketsPopover, 'show');
|
||||||
controller.showLastTickets({});
|
controller.showLastTickets({});
|
||||||
|
|
||||||
expect(controller.$.lastTicketsModel.refresh).toHaveBeenCalledWith();
|
expect(controller.$.lastTicketsModel.refresh).toHaveBeenCalledWith();
|
||||||
|
@ -123,9 +123,9 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('importTicketLines()', () => {
|
describe('importTicketLines()', () => {
|
||||||
it('should perform a post query and add lines from an existent ticket', () => {
|
it('should perform a post query and add lines from an existent ticket', () => {
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$.lastTicketsPopover, 'hide');
|
jest.spyOn(controller.$.lastTicketsPopover, 'hide');
|
||||||
let data = {claimFk: 1, ticketFk: 1};
|
let data = {claimFk: 1, ticketFk: 1};
|
||||||
$httpBackend.expect('POST', `ClaimEnds/importTicketSales`, data).respond({});
|
$httpBackend.expect('POST', `ClaimEnds/importTicketSales`, data).respond({});
|
||||||
controller.importTicketLines(1);
|
controller.importTicketLines(1);
|
||||||
|
@ -139,8 +139,8 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('regularize()', () => {
|
describe('regularize()', () => {
|
||||||
it('should perform a post query and reload the claim card', () => {
|
it('should perform a post query and reload the claim card', () => {
|
||||||
spyOn(controller.card, 'reload');
|
jest.spyOn(controller.card, 'reload');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
let data = {claimFk: $state.params.id};
|
let data = {claimFk: $state.params.id};
|
||||||
$httpBackend.expect('POST', `Claims/regularizeClaim`, data).respond({});
|
$httpBackend.expect('POST', `Claims/regularizeClaim`, data).respond({});
|
||||||
|
@ -156,9 +156,9 @@ describe('claim', () => {
|
||||||
const greugeTypeId = 7;
|
const greugeTypeId = 7;
|
||||||
const freightPickUpPrice = 11;
|
const freightPickUpPrice = 11;
|
||||||
it('should do nothing', () => {
|
it('should do nothing', () => {
|
||||||
spyOn(controller.$http, 'post');
|
jest.spyOn(controller.$http, 'post');
|
||||||
spyOn(controller.card, 'reload');
|
jest.spyOn(controller.card, 'reload');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
controller.onUpdateGreugeResponse('cancel');
|
controller.onUpdateGreugeResponse('cancel');
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ describe('claim', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should make a query and get the greugeTypeId and greuge config', () => {
|
it('should make a query and get the greugeTypeId and greuge config', () => {
|
||||||
spyOn(controller.card, 'reload');
|
jest.spyOn(controller.card, 'reload');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
const greugeTypeParams = $httpParamSerializer({filter: {where: {code: 'freightPickUp'}}});
|
const greugeTypeParams = $httpParamSerializer({filter: {where: {code: 'freightPickUp'}}});
|
||||||
$httpBackend.expect('GET', `GreugeTypes/findOne?${greugeTypeParams}`).respond({id: greugeTypeId});
|
$httpBackend.expect('GET', `GreugeTypes/findOne?${greugeTypeParams}`).respond({id: greugeTypeId});
|
||||||
|
@ -183,13 +183,13 @@ describe('claim', () => {
|
||||||
|
|
||||||
// #1957 - Investigate how to test nested httpBackend requests
|
// #1957 - Investigate how to test nested httpBackend requests
|
||||||
xit('should perform a insert into greuges', () => {
|
xit('should perform a insert into greuges', () => {
|
||||||
spyOn(controller.card, 'reload');
|
jest.spyOn(controller.card, 'reload');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
spyOn(controller, 'getGreugeTypeId').and.returnValue(new Promise(resolve => {
|
jest.spyOn(controller, 'getGreugeTypeId').and.returnValue(new Promise(resolve => {
|
||||||
return resolve({id: greugeTypeId});
|
return resolve({id: greugeTypeId});
|
||||||
}));
|
}));
|
||||||
spyOn(controller, 'getGreugeConfig').and.returnValue(new Promise(resolve => {
|
jest.spyOn(controller, 'getGreugeConfig').and.returnValue(new Promise(resolve => {
|
||||||
return resolve({freightPickUpPrice});
|
return resolve({freightPickUpPrice});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe('Claim', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should redirect to 'claim.card.detail' state`, () => {
|
it(`should redirect to 'claim.card.detail' state`, () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.detail');
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.detail');
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('Item Component vnClaimDescriptor', () => {
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(params);
|
const serializedParams = $httpParamSerializer(params);
|
||||||
let expectedPath = `api/report/claim-pickup-order?${serializedParams}`;
|
let expectedPath = `api/report/claim-pickup-order?${serializedParams}`;
|
||||||
spyOn(window, 'open');
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
controller.showPickupOrder();
|
controller.showPickupOrder();
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
||||||
|
@ -43,7 +43,7 @@ describe('Item Component vnClaimDescriptor', () => {
|
||||||
|
|
||||||
describe('sendPickupOrder(response)', () => {
|
describe('sendPickupOrder(response)', () => {
|
||||||
it('should make a query and call vnApp.showMessage() if the response is accept', () => {
|
it('should make a query and call vnApp.showMessage() if the response is accept', () => {
|
||||||
spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
recipient: 'client@email',
|
recipient: 'client@email',
|
||||||
|
@ -78,8 +78,8 @@ describe('Item Component vnClaimDescriptor', () => {
|
||||||
let response = 'accept';
|
let response = 'accept';
|
||||||
controller.claim = {id: 2};
|
controller.claim = {id: 2};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
$httpBackend.when('DELETE', `Claims/2`).respond(200);
|
$httpBackend.when('DELETE', `Claims/2`).respond(200);
|
||||||
$httpBackend.expect('DELETE', `Claims/2`);
|
$httpBackend.expect('DELETE', `Claims/2`);
|
||||||
controller.deleteClaim(response);
|
controller.deleteClaim(response);
|
||||||
|
|
|
@ -37,8 +37,8 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('openAddSalesDialog()', () => {
|
describe('openAddSalesDialog()', () => {
|
||||||
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
||||||
spyOn(controller, 'getClaimableFromTicket');
|
jest.spyOn(controller, 'getClaimableFromTicket');
|
||||||
spyOn(controller.$.addSales, 'show');
|
jest.spyOn(controller.$.addSales, 'show');
|
||||||
controller.openAddSalesDialog();
|
controller.openAddSalesDialog();
|
||||||
|
|
||||||
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
||||||
|
@ -58,8 +58,8 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('addClaimedSale(index)', () => {
|
describe('addClaimedSale(index)', () => {
|
||||||
it('should make a post and call refresh, hide and showSuccess', () => {
|
it('should make a post and call refresh, hide and showSuccess', () => {
|
||||||
spyOn(controller.$.addSales, 'hide');
|
jest.spyOn(controller.$.addSales, 'hide');
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
$httpBackend.expectPOST(`ClaimBeginnings/`).respond({});
|
$httpBackend.expectPOST(`ClaimBeginnings/`).respond({});
|
||||||
controller.addClaimedSale(1);
|
controller.addClaimedSale(1);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -71,7 +71,7 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('deleteClaimedSale(index)', () => {
|
describe('deleteClaimedSale(index)', () => {
|
||||||
it('should make a delete and call refresh and showSuccess', () => {
|
it('should make a delete and call refresh and showSuccess', () => {
|
||||||
spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
$httpBackend.expectDELETE(`ClaimBeginnings/1`).respond({});
|
$httpBackend.expectDELETE(`ClaimBeginnings/1`).respond({});
|
||||||
controller.deleteClaimedSale(0);
|
controller.deleteClaimedSale(0);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -82,7 +82,7 @@ describe('claim', () => {
|
||||||
|
|
||||||
describe('setClaimedQuantity(id, claimedQuantity)', () => {
|
describe('setClaimedQuantity(id, claimedQuantity)', () => {
|
||||||
it('should make a patch and call refresh and showSuccess', () => {
|
it('should make a patch and call refresh and showSuccess', () => {
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
$httpBackend.expectPATCH(`ClaimBeginnings/`).respond({});
|
$httpBackend.expectPATCH(`ClaimBeginnings/`).respond({});
|
||||||
controller.setClaimedQuantity(1, 1);
|
controller.setClaimedQuantity(1, 1);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
@ -112,10 +112,10 @@ describe('claim', () => {
|
||||||
controller.newDiscount = 10;
|
controller.newDiscount = 10;
|
||||||
|
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller, 'calculateTotals');
|
jest.spyOn(controller, 'calculateTotals');
|
||||||
spyOn(controller, 'clearDiscount');
|
jest.spyOn(controller, 'clearDiscount');
|
||||||
spyOn(controller.$.editPopover, 'hide');
|
jest.spyOn(controller.$.editPopover, 'hide');
|
||||||
|
|
||||||
$httpBackend.when('POST', 'Tickets/1/updateDiscount').respond({});
|
$httpBackend.when('POST', 'Tickets/1/updateDiscount').respond({});
|
||||||
controller.updateDiscount();
|
controller.updateDiscount();
|
||||||
|
@ -135,8 +135,8 @@ describe('claim', () => {
|
||||||
stopImmediatePropagation: () => {},
|
stopImmediatePropagation: () => {},
|
||||||
target: 'the target element'
|
target: 'the target element'
|
||||||
};
|
};
|
||||||
spyOn(event, 'stopImmediatePropagation');
|
jest.spyOn(event, 'stopImmediatePropagation');
|
||||||
spyOn(controller.$.descriptor, 'show');
|
jest.spyOn(controller.$.descriptor, 'show');
|
||||||
|
|
||||||
controller.showItemDescriptor(event, itemId);
|
controller.showItemDescriptor(event, itemId);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Claim', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should redirect to 'claim.card.action' state`, () => {
|
it(`should redirect to 'claim.card.action' state`, () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.action');
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.action');
|
||||||
|
|
|
@ -28,8 +28,8 @@ describe('Claim', () => {
|
||||||
it('should make an HTTP Post query', () => {
|
it('should make an HTTP Post query', () => {
|
||||||
const dmsId = 1;
|
const dmsId = 1;
|
||||||
const dmsIndex = 0;
|
const dmsIndex = 0;
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
controller.photos = [{dmsFk: 1}];
|
controller.photos = [{dmsFk: 1}];
|
||||||
controller.dmsIndex = dmsIndex;
|
controller.dmsIndex = dmsIndex;
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ describe('Claim', () => {
|
||||||
it('should make an HTTP Post query, then refresh the model data', () => {
|
it('should make an HTTP Post query, then refresh the model data', () => {
|
||||||
const claimId = 1;
|
const claimId = 1;
|
||||||
const dmsIndex = 0;
|
const dmsIndex = 0;
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
controller.photos = [{dmsFk: 1}];
|
controller.photos = [{dmsFk: 1}];
|
||||||
controller.dmsIndex = dmsIndex;
|
controller.dmsIndex = dmsIndex;
|
||||||
controller.dms = {files: []};
|
controller.dms = {files: []};
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe('Claim', () => {
|
||||||
|
|
||||||
describe('$onChanges()', () => {
|
describe('$onChanges()', () => {
|
||||||
it('should call getSummary when item.id is defined', () => {
|
it('should call getSummary when item.id is defined', () => {
|
||||||
spyOn(controller, 'getSummary');
|
jest.spyOn(controller, 'getSummary');
|
||||||
controller.$onChanges();
|
controller.$onChanges();
|
||||||
|
|
||||||
expect(controller.getSummary).toHaveBeenCalledWith();
|
expect(controller.getSummary).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -35,7 +35,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should perform a PATCH and not set value to defaultAddressFk property', () => {
|
it('should perform a PATCH and not set value to defaultAddressFk property', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
controller.address.isDefaultAddress = false;
|
controller.address.isDefaultAddress = false;
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should perform a PATCH and set a value to defaultAddressFk property', () => {
|
it('should perform a PATCH and set a value to defaultAddressFk property', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
controller.address.isDefaultAddress = true;
|
controller.address.isDefaultAddress = true;
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('removeObservation()', () => {
|
describe('removeObservation()', () => {
|
||||||
it('should call $.watcher.setDirty() and $.model.remove(index)', () => {
|
it('should call $.watcher.setDirty() and $.model.remove(index)', () => {
|
||||||
spyOn(controller.$.watcher, 'setDirty');
|
jest.spyOn(controller.$.watcher, 'setDirty');
|
||||||
spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
controller.removeObservation(1);
|
controller.removeObservation(1);
|
||||||
|
|
||||||
expect(controller.$.model.remove).toHaveBeenCalledWith(1);
|
expect(controller.$.model.remove).toHaveBeenCalledWith(1);
|
||||||
|
@ -47,7 +47,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('cancel()', () => {
|
describe('cancel()', () => {
|
||||||
it('should call goToIndex()', () => {
|
it('should call goToIndex()', () => {
|
||||||
spyOn(controller, 'goToIndex');
|
jest.spyOn(controller, 'goToIndex');
|
||||||
controller.cancel();
|
controller.cancel();
|
||||||
|
|
||||||
expect(controller.goToIndex).toHaveBeenCalledWith();
|
expect(controller.goToIndex).toHaveBeenCalledWith();
|
||||||
|
@ -56,7 +56,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('goToIndex()', () => {
|
describe('goToIndex()', () => {
|
||||||
it('should call $state.go("client.card.address.index")', () => {
|
it('should call $state.go("client.card.address.index")', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
controller.goToIndex();
|
controller.goToIndex();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('client.card.address.index');
|
expect(controller.$state.go).toHaveBeenCalledWith('client.card.address.index');
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('setDefault()', () => {
|
describe('setDefault()', () => {
|
||||||
it('should perform a PATCH and set a value to defaultAddressFk property', () => {
|
it('should perform a PATCH and set a value to defaultAddressFk property', () => {
|
||||||
spyOn(controller, 'sortAddresses');
|
jest.spyOn(controller, 'sortAddresses');
|
||||||
let address = {id: 1};
|
let address = {id: 1};
|
||||||
let data = {defaultAddressFk: address.id};
|
let data = {defaultAddressFk: address.id};
|
||||||
let expectedResult = {defaultAddressFk: address.id};
|
let expectedResult = {defaultAddressFk: address.id};
|
||||||
|
|
|
@ -31,9 +31,9 @@ describe('Client', () => {
|
||||||
it('should apply the filters on he models and get the client balance', () => {
|
it('should apply the filters on he models and get the client balance', () => {
|
||||||
controller._companyId = 442;
|
controller._companyId = 442;
|
||||||
controller.$stateParams.id = 101;
|
controller.$stateParams.id = 101;
|
||||||
spyOn(controller, 'getBalances');
|
jest.spyOn(controller, 'getBalances').mockReturnThis();
|
||||||
spyOn(controller.$.model, 'applyFilter').and.returnValue(Promise.resolve());
|
jest.spyOn(controller.$.model, 'applyFilter').mockReturnValue(Promise.resolve());
|
||||||
spyOn(controller.$.riskModel, 'applyFilter').and.returnValue(Promise.resolve());
|
jest.spyOn(controller.$.riskModel, 'applyFilter').mockReturnValue(Promise.resolve());
|
||||||
|
|
||||||
controller.getData().then(() => {
|
controller.getData().then(() => {
|
||||||
expect(controller.$.model.applyFilter).toHaveBeenCalledWith(null, {'clientId': 101, 'companyId': 442});
|
expect(controller.$.model.applyFilter).toHaveBeenCalledWith(null, {'clientId': 101, 'companyId': 442});
|
||||||
|
@ -45,7 +45,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('company setter/getter', () => {
|
describe('company setter/getter', () => {
|
||||||
it('should return the company and then call getData()', () => {
|
it('should return the company and then call getData()', () => {
|
||||||
spyOn(controller, 'getData');
|
jest.spyOn(controller, 'getData').mockReturnThis();
|
||||||
controller.companyId = 442;
|
controller.companyId = 442;
|
||||||
|
|
||||||
expect(controller._companyId).toEqual(442);
|
expect(controller._companyId).toEqual(442);
|
||||||
|
@ -64,7 +64,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('getBalances()', () => {
|
describe('getBalances()', () => {
|
||||||
it('should return the total client balance amount', () => {
|
it('should return the total client balance amount', () => {
|
||||||
spyOn(controller, 'getCurrentBalance').and.callThrough();
|
jest.spyOn(controller, 'getCurrentBalance');
|
||||||
controller._companyId = 442;
|
controller._companyId = 442;
|
||||||
controller.$.model = {data:
|
controller.$.model = {data:
|
||||||
[{
|
[{
|
||||||
|
@ -94,7 +94,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('balances() setter', () => {
|
describe('balances() setter', () => {
|
||||||
it('should set the balances data and not call the getBalances() method', () => {
|
it('should set the balances data and not call the getBalances() method', () => {
|
||||||
spyOn(controller, 'getBalances');
|
jest.spyOn(controller, 'getBalances');
|
||||||
controller.$.riskModel.data = null;
|
controller.$.riskModel.data = null;
|
||||||
controller.balances = [{
|
controller.balances = [{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -115,7 +115,7 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the balances data and then call the getBalances() method', () => {
|
it('should set the balances data and then call the getBalances() method', () => {
|
||||||
spyOn(controller, 'getBalances');
|
jest.spyOn(controller, 'getBalances').mockReturnThis();
|
||||||
controller.balances = [{
|
controller.balances = [{
|
||||||
id: 1,
|
id: 1,
|
||||||
debit: 1000,
|
debit: 1000,
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('Client', () => {
|
||||||
vnApp = _vnApp_;
|
vnApp = _vnApp_;
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$scope.watcher = {};
|
$scope.watcher = {};
|
||||||
spyOn(vnApp, 'showError');
|
jest.spyOn(vnApp, 'showError');
|
||||||
controller = $componentController('vnClientBillingData', {$element, $scope});
|
controller = $componentController('vnClientBillingData', {$element, $scope});
|
||||||
controller.client = {id: 101, name: 'Client name', payMethodFk: 4};
|
controller.client = {id: 101, name: 'Client name', payMethodFk: 4};
|
||||||
$scope.watcher.orgData = {id: 101, name: 'Client name', payMethodFk: 4};
|
$scope.watcher.orgData = {id: 101, name: 'Client name', payMethodFk: 4};
|
||||||
|
|
|
@ -33,7 +33,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('client.card.basicData', {id: '1234'});
|
expect(controller.$state.go).toHaveBeenCalledWith('client.card.basicData', {id: '1234'});
|
||||||
|
|
|
@ -60,7 +60,7 @@ describe('Client', () => {
|
||||||
describe('closeContract()', () => {
|
describe('closeContract()', () => {
|
||||||
it('should define the classificationId property of the controller and then call the show method()', () => {
|
it('should define the classificationId property of the controller and then call the show method()', () => {
|
||||||
controller.$scope.closeContract = {show: () => {}};
|
controller.$scope.closeContract = {show: () => {}};
|
||||||
spyOn(controller.$scope.closeContract, 'show');
|
jest.spyOn(controller.$scope.closeContract, 'show');
|
||||||
|
|
||||||
expect(controller.classificationId).toBeFalsy();
|
expect(controller.classificationId).toBeFalsy();
|
||||||
controller.closeContract({id: 1});
|
controller.closeContract({id: 1});
|
||||||
|
@ -72,7 +72,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('returnDialog()', () => {
|
describe('returnDialog()', () => {
|
||||||
it('should call the returnDialog method and perform a PATCH query, then call _getClassifications method', () => {
|
it('should call the returnDialog method and perform a PATCH query, then call _getClassifications method', () => {
|
||||||
spyOn(controller, '_getClassifications');
|
jest.spyOn(controller, '_getClassifications').mockReturnThis();
|
||||||
controller.classificationId = 1;
|
controller.classificationId = 1;
|
||||||
$httpBackend.when('PATCH', `CreditClassifications/1`).respond(200);
|
$httpBackend.when('PATCH', `CreditClassifications/1`).respond(200);
|
||||||
$httpBackend.expect('PATCH', `CreditClassifications/1`);
|
$httpBackend.expect('PATCH', `CreditClassifications/1`);
|
||||||
|
|
|
@ -42,7 +42,7 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call show() method when the client have a recovery', () => {
|
it('should call show() method when the client have a recovery', () => {
|
||||||
spyOn(controller.$scope.confirmation, 'show');
|
jest.spyOn(controller.$scope.confirmation, 'show');
|
||||||
$httpBackend.whenGET(`Recoveries/101/hasActiveRecovery`).respond(true);
|
$httpBackend.whenGET(`Recoveries/101/hasActiveRecovery`).respond(true);
|
||||||
$httpBackend.expectGET(`Recoveries/101/hasActiveRecovery`);
|
$httpBackend.expectGET(`Recoveries/101/hasActiveRecovery`);
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
@ -52,7 +52,7 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call addCredit() method when the client doesnt have a recovery', () => {
|
it('should call addCredit() method when the client doesnt have a recovery', () => {
|
||||||
spyOn(controller, 'addCredit');
|
jest.spyOn(controller, 'addCredit');
|
||||||
$httpBackend.whenGET(`Recoveries/101/hasActiveRecovery`).respond(false);
|
$httpBackend.whenGET(`Recoveries/101/hasActiveRecovery`).respond(false);
|
||||||
$httpBackend.expectGET(`Recoveries/101/hasActiveRecovery`);
|
$httpBackend.expectGET(`Recoveries/101/hasActiveRecovery`);
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
@ -64,7 +64,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('cancel()', () => {
|
describe('cancel()', () => {
|
||||||
it('should call goToIndex()', () => {
|
it('should call goToIndex()', () => {
|
||||||
spyOn(controller, 'goToIndex');
|
jest.spyOn(controller, 'goToIndex');
|
||||||
controller.cancel();
|
controller.cancel();
|
||||||
|
|
||||||
expect(controller.goToIndex).toHaveBeenCalledWith();
|
expect(controller.goToIndex).toHaveBeenCalledWith();
|
||||||
|
@ -73,7 +73,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('returnDialog()', () => {
|
describe('returnDialog()', () => {
|
||||||
it('should call addCredit() when is called with accept', () => {
|
it('should call addCredit() when is called with accept', () => {
|
||||||
spyOn(controller, 'addCredit');
|
jest.spyOn(controller, 'addCredit');
|
||||||
controller.returnDialog('accept');
|
controller.returnDialog('accept');
|
||||||
|
|
||||||
expect(controller.addCredit).toHaveBeenCalledWith();
|
expect(controller.addCredit).toHaveBeenCalledWith();
|
||||||
|
@ -82,7 +82,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('addCredit()', () => {
|
describe('addCredit()', () => {
|
||||||
it('should call the function go() on $state to go to the credit list', () => {
|
it('should call the function go() on $state to go to the credit list', () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
client.credit = 1;
|
client.credit = 1;
|
||||||
controller.addCredit();
|
controller.addCredit();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe('Client', () => {
|
||||||
it(`should not apply any changes if the received id is the same stored in _clientFk`, () => {
|
it(`should not apply any changes if the received id is the same stored in _clientFk`, () => {
|
||||||
controller.client = 'I exist!';
|
controller.client = 'I exist!';
|
||||||
controller._clientFk = 1;
|
controller._clientFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.clientFk = 1;
|
controller.clientFk = 1;
|
||||||
|
|
||||||
expect(controller.client).toEqual('I exist!');
|
expect(controller.client).toEqual('I exist!');
|
||||||
|
@ -34,7 +34,7 @@ describe('Client', () => {
|
||||||
it(`should set the received id into _clientFk, set the client to null and then call getCard()`, () => {
|
it(`should set the received id into _clientFk, set the client to null and then call getCard()`, () => {
|
||||||
controller.client = `Please don't`;
|
controller.client = `Please don't`;
|
||||||
controller._clientFk = 1;
|
controller._clientFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.clientFk = 999;
|
controller.clientFk = 999;
|
||||||
|
|
||||||
expect(controller.client).toBeNull();
|
expect(controller.client).toBeNull();
|
||||||
|
@ -45,7 +45,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('client()', () => {
|
describe('client()', () => {
|
||||||
it(`should save the client into _client and then call relocate()`, () => {
|
it(`should save the client into _client and then call relocate()`, () => {
|
||||||
spyOn(controller.$.popover, 'relocate');
|
jest.spyOn(controller.$.popover, 'relocate');
|
||||||
controller.client = `i'm the client!`;
|
controller.client = `i'm the client!`;
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should call the show()`, () => {
|
it(`should call the show()`, () => {
|
||||||
spyOn(controller.$.popover, 'show');
|
jest.spyOn(controller.$.popover, 'show');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('client() setter', () => {
|
describe('client() setter', () => {
|
||||||
it('should set the client data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the client data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
jest.spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller.client = {
|
controller.client = {
|
||||||
id: 15,
|
id: 15,
|
||||||
name: 'Bruce wayne'
|
name: 'Bruce wayne'
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('client() setter', () => {
|
describe('client() setter', () => {
|
||||||
it('should set the client data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the client data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
jest.spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller._client = undefined;
|
controller._client = undefined;
|
||||||
controller.client = {
|
controller.client = {
|
||||||
id: 15
|
id: 15
|
||||||
|
|
|
@ -22,8 +22,8 @@ describe('Client', () => {
|
||||||
it('should make an HTTP Post query', () => {
|
it('should make an HTTP Post query', () => {
|
||||||
const dmsId = 1;
|
const dmsId = 1;
|
||||||
const dmsIndex = 0;
|
const dmsIndex = 0;
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
controller.clientDms = [{dmsFk: 1}];
|
controller.clientDms = [{dmsFk: 1}];
|
||||||
controller.dmsIndex = dmsIndex;
|
controller.dmsIndex = dmsIndex;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should call the save() method directly', () => {
|
it('should call the save() method directly', () => {
|
||||||
spyOn(controller, 'save');
|
jest.spyOn(controller, 'save');
|
||||||
|
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the checkExistingClient() if the isTaxDataChecked property is checked', () => {
|
it('should call the checkExistingClient() if the isTaxDataChecked property is checked', () => {
|
||||||
spyOn(controller, 'save');
|
jest.spyOn(controller, 'save');
|
||||||
spyOn(controller, 'checkExistingClient');
|
jest.spyOn(controller, 'checkExistingClient');
|
||||||
|
|
||||||
controller.client.isTaxDataChecked = true;
|
controller.client.isTaxDataChecked = true;
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
@ -51,7 +51,7 @@ describe('Client', () => {
|
||||||
describe('checkExistingClient()', () => {
|
describe('checkExistingClient()', () => {
|
||||||
it('should show a save confirmation when a duplicated client is found and then set the despiteOfClient property', () => {
|
it('should show a save confirmation when a duplicated client is found and then set the despiteOfClient property', () => {
|
||||||
controller.$.confirmDuplicatedClient = {show: () => {}};
|
controller.$.confirmDuplicatedClient = {show: () => {}};
|
||||||
spyOn(controller.$.confirmDuplicatedClient, 'show');
|
jest.spyOn(controller.$.confirmDuplicatedClient, 'show');
|
||||||
const filterObj = {
|
const filterObj = {
|
||||||
where: {
|
where: {
|
||||||
and: [
|
and: [
|
||||||
|
@ -74,7 +74,7 @@ describe('Client', () => {
|
||||||
describe('checkEtChanges()', () => {
|
describe('checkEtChanges()', () => {
|
||||||
it(`should show a propagation confirmation if isEqualizated property is changed and invoice by address is checked`, () => {
|
it(`should show a propagation confirmation if isEqualizated property is changed and invoice by address is checked`, () => {
|
||||||
controller.$.propagateIsEqualizated = {show: () => {}};
|
controller.$.propagateIsEqualizated = {show: () => {}};
|
||||||
spyOn(controller.$.propagateIsEqualizated, 'show');
|
jest.spyOn(controller.$.propagateIsEqualizated, 'show');
|
||||||
|
|
||||||
const orgData = $scope.watcher.orgData;
|
const orgData = $scope.watcher.orgData;
|
||||||
orgData.hasToInvoiceByAddress = true;
|
orgData.hasToInvoiceByAddress = true;
|
||||||
|
@ -86,7 +86,7 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should call to the onAcceptEt() method if isEqualizated property is changed and invoice by address isn't checked`, () => {
|
it(`should call to the onAcceptEt() method if isEqualizated property is changed and invoice by address isn't checked`, () => {
|
||||||
spyOn(controller, 'onAcceptEt');
|
jest.spyOn(controller, 'onAcceptEt');
|
||||||
|
|
||||||
const orgData = $scope.watcher.orgData;
|
const orgData = $scope.watcher.orgData;
|
||||||
orgData.hasToInvoiceByAddress = false;
|
orgData.hasToInvoiceByAddress = false;
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should call the function go() on $state to go to the greuges list', () => {
|
it('should call the function go() on $state to go to the greuges list', () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('client.card.greuge.index');
|
expect(controller.$state.go).toHaveBeenCalledWith('client.card.greuge.index');
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe('Client index', () => {
|
||||||
it('should navigate to the ticket index using params as filter', () => {
|
it('should navigate to the ticket index using params as filter', () => {
|
||||||
const client = {id: 101};
|
const client = {id: 101};
|
||||||
const event = new MouseEvent('click', {cancelable: true});
|
const event = new MouseEvent('click', {cancelable: true});
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
|
|
||||||
controller.filterTickets(client, event);
|
controller.filterTickets(client, event);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Client', () => {
|
||||||
let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
||||||
controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
$httpBackend.when('PATCH', `postcodes`, params).respond(200, params);
|
$httpBackend.when('PATCH', `postcodes`, params).respond(200, params);
|
||||||
$httpBackend.expect('PATCH', `postcodes`, params).respond(params);
|
$httpBackend.expect('PATCH', `postcodes`, params).respond(params);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should call the function go() on $state to go to the recovery list', () => {
|
it('should call the function go() on $state to go to the recovery list', () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('client.card.recovery.index');
|
expect(controller.$state.go).toHaveBeenCalledWith('client.card.recovery.index');
|
||||||
|
|
|
@ -52,7 +52,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call sendSample() method`, () => {
|
it(`should call sendSample() method`, () => {
|
||||||
spyOn(controller, 'sendSample');
|
jest.spyOn(controller, 'sendSample');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.sendSample).toHaveBeenCalledWith();
|
expect(controller.sendSample).toHaveBeenCalledWith();
|
||||||
|
@ -61,7 +61,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('send()', () => {
|
describe('send()', () => {
|
||||||
it(`should not perform an HTTP query if no recipient is specified`, () => {
|
it(`should not perform an HTTP query if no recipient is specified`, () => {
|
||||||
spyOn(controller.$http, 'get');
|
jest.spyOn(controller.$http, 'get');
|
||||||
|
|
||||||
controller.$.sampleType.selection = {
|
controller.$.sampleType.selection = {
|
||||||
hasCompany: false,
|
hasCompany: false,
|
||||||
|
@ -77,7 +77,7 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should not perform an HTTP query if no sample is specified`, () => {
|
it(`should not perform an HTTP query if no sample is specified`, () => {
|
||||||
spyOn(controller.$http, 'get');
|
jest.spyOn(controller.$http, 'get');
|
||||||
|
|
||||||
controller.$.sampleType.selection = null;
|
controller.$.sampleType.selection = null;
|
||||||
controller.clientSample = {
|
controller.clientSample = {
|
||||||
|
@ -91,7 +91,7 @@ describe('Client', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should not perform an HTTP query if company is required and not specified`, () => {
|
it(`should not perform an HTTP query if company is required and not specified`, () => {
|
||||||
spyOn(controller.$http, 'get');
|
jest.spyOn(controller.$http, 'get');
|
||||||
|
|
||||||
controller.$.sampleType.selection = {
|
controller.$.sampleType.selection = {
|
||||||
hasCompany: true,
|
hasCompany: true,
|
||||||
|
@ -152,7 +152,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('showPreview()', () => {
|
describe('showPreview()', () => {
|
||||||
it(`should open a sample preview`, () => {
|
it(`should open a sample preview`, () => {
|
||||||
spyOn(controller.$.showPreview, 'show');
|
jest.spyOn(controller.$.showPreview, 'show');
|
||||||
|
|
||||||
controller.send = (isPreview, cb) => {
|
controller.send = (isPreview, cb) => {
|
||||||
cb({
|
cb({
|
||||||
|
@ -167,7 +167,7 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('sendSample()', () => {
|
describe('sendSample()', () => {
|
||||||
it(`should perform a query (GET) and call go() method`, () => {
|
it(`should perform a query (GET) and call go() method`, () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
controller.send = (isPreview, cb) => {
|
controller.send = (isPreview, cb) => {
|
||||||
cb({
|
cb({
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('Client', () => {
|
||||||
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||||
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
$httpBackend.expect('POST', `Clients/101/sendSms`, params).respond(200, params);
|
$httpBackend.expect('POST', `Clients/101/sendSms`, params).respond(200, params);
|
||||||
|
|
||||||
controller.onResponse('accept');
|
controller.onResponse('accept');
|
||||||
|
@ -39,7 +39,7 @@ describe('Client', () => {
|
||||||
it('should call onResponse without the destination and show an error snackbar', () => {
|
it('should call onResponse without the destination and show an error snackbar', () => {
|
||||||
controller.sms = {destinationFk: 101, message: 'My SMS'};
|
controller.sms = {destinationFk: 101, message: 'My SMS'};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showError');
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
controller.onResponse('accept');
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ describe('Client', () => {
|
||||||
it('should call onResponse without the message and show an error snackbar', () => {
|
it('should call onResponse without the message and show an error snackbar', () => {
|
||||||
controller.sms = {destinationFk: 101, destination: 222222222};
|
controller.sms = {destinationFk: 101, destination: 222222222};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showError');
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
controller.onResponse('accept');
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@ describe('Client', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('$onChanges()', () => {
|
describe('$onChanges()', () => {
|
||||||
it('should perform a GET query and define summary property', () => {
|
it('should perform a GET query and then define the summary property', () => {
|
||||||
let res = {name: 'Superman', classifications: []};
|
let res = {name: 'Superman', classifications: []};
|
||||||
|
|
||||||
spyOn(controller, 'sumRisk');
|
jest.spyOn(controller, 'sumRisk').mockReturnThis();
|
||||||
$httpBackend.when('GET', `Clients/101/summary`).respond(200, res);
|
$httpBackend.when('GET', `Clients/101/summary`).respond(200, res);
|
||||||
$httpBackend.expect('GET', `Clients/101/summary`);
|
$httpBackend.expect('GET', `Clients/101/summary`);
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ describe('Component VnClientWebAccess', () => {
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
vnApp = _vnApp_;
|
vnApp = _vnApp_;
|
||||||
spyOn(vnApp, 'showError');
|
jest.spyOn(vnApp, 'showError');
|
||||||
controller = $componentController('vnClientWebAccess', {$scope});
|
controller = $componentController('vnClientWebAccess', {$scope});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('$onChanges()', () => {
|
describe('$onChanges()', () => {
|
||||||
it(`should pass client's account data to account then call isCustomer function`, () => {
|
it(`should pass client's account data to account then call isCustomer function`, () => {
|
||||||
spyOn(controller, 'isCustomer');
|
jest.spyOn(controller, 'isCustomer');
|
||||||
controller.client = {client: 'Bruce Wayne', account: 'Wayne Industries'};
|
controller.client = {client: 'Bruce Wayne', account: 'Wayne Industries'};
|
||||||
controller.account = {};
|
controller.account = {};
|
||||||
controller.$onChanges();
|
controller.$onChanges();
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('Component vnClientWebPayment', () => {
|
||||||
$scope.model = crudModel;
|
$scope.model = crudModel;
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
vnApp = _vnApp_;
|
vnApp = _vnApp_;
|
||||||
spyOn(vnApp, 'showError');
|
jest.spyOn(vnApp, 'showError');
|
||||||
controller = $componentController('vnClientWebPayment', {$scope: $scope});
|
controller = $componentController('vnClientWebPayment', {$scope: $scope});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe('Entry Component vnEntryDescriptor', () => {
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(params);
|
const serializedParams = $httpParamSerializer(params);
|
||||||
let expectedPath = `api/report/entry-order?${serializedParams}`;
|
let expectedPath = `api/report/entry-order?${serializedParams}`;
|
||||||
spyOn(window, 'open');
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
controller.showEntryReport();
|
controller.showEntryReport();
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('component vnEntrySummary', () => {
|
||||||
|
|
||||||
describe('entry setter/getter', () => {
|
describe('entry setter/getter', () => {
|
||||||
it('should check if value.id is defined', () => {
|
it('should check if value.id is defined', () => {
|
||||||
spyOn(controller, 'getEntryData');
|
jest.spyOn(controller, 'getEntryData');
|
||||||
|
|
||||||
controller.entry = {id: 1};
|
controller.entry = {id: 1};
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ describe('component vnEntrySummary', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the entry and then call getEntryData()', () => {
|
it('should return the entry and then call getEntryData()', () => {
|
||||||
spyOn(controller, 'getEntryData');
|
jest.spyOn(controller, 'getEntryData');
|
||||||
controller.entry = {id: 99};
|
controller.entry = {id: 99};
|
||||||
|
|
||||||
expect(controller._entry.id).toEqual(99);
|
expect(controller._entry.id).toEqual(99);
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('item.card.basicData', {id: 1});
|
expect(controller.$state.go).toHaveBeenCalledWith('item.card.basicData', {id: 1});
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe('Item', () => {
|
||||||
it(`should not apply any changes if the received id is the same stored in _itemFk`, () => {
|
it(`should not apply any changes if the received id is the same stored in _itemFk`, () => {
|
||||||
controller.item = 'I exist!';
|
controller.item = 'I exist!';
|
||||||
controller._itemFk = 1;
|
controller._itemFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.itemFk = 1;
|
controller.itemFk = 1;
|
||||||
|
|
||||||
expect(controller.item).toEqual('I exist!');
|
expect(controller.item).toEqual('I exist!');
|
||||||
|
@ -34,7 +34,7 @@ describe('Item', () => {
|
||||||
it(`should set the received id into _itemFk, set the item to null and then call getCard()`, () => {
|
it(`should set the received id into _itemFk, set the item to null and then call getCard()`, () => {
|
||||||
controller.item = `Please don't`;
|
controller.item = `Please don't`;
|
||||||
controller._itemFk = 1;
|
controller._itemFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.itemFk = 999;
|
controller.itemFk = 999;
|
||||||
|
|
||||||
expect(controller.item).toBeNull();
|
expect(controller.item).toBeNull();
|
||||||
|
@ -45,7 +45,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('item()', () => {
|
describe('item()', () => {
|
||||||
it(`should save the item into _item and then call relocate()`, () => {
|
it(`should save the item into _item and then call relocate()`, () => {
|
||||||
spyOn(controller.$.popover, 'relocate');
|
jest.spyOn(controller.$.popover, 'relocate');
|
||||||
controller.item = `i'm the item!`;
|
controller.item = `i'm the item!`;
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should call the show()`, () => {
|
it(`should call the show()`, () => {
|
||||||
spyOn(controller.$.popover, 'show');
|
jest.spyOn(controller.$.popover, 'show');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -68,8 +68,8 @@ describe('Item', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('set item()', () => {
|
describe('set item()', () => {
|
||||||
it(`should set warehouseFk property based on itemType warehouseFk`, () => {
|
it('should set warehouseFk property based on itemType warehouseFk', () => {
|
||||||
spyOn(controller.$scope, '$applyAsync').and.callThrough();
|
jest.spyOn(controller.$scope, '$applyAsync');
|
||||||
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
||||||
|
|
||||||
expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
|
@ -80,7 +80,7 @@ describe('Item', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should set warehouseFk property based on url query warehouseFk`, () => {
|
it(`should set warehouseFk property based on url query warehouseFk`, () => {
|
||||||
spyOn(controller.$scope, '$applyAsync').and.callThrough();
|
jest.spyOn(controller.$scope, '$applyAsync');
|
||||||
controller.$stateParams.warehouseFk = 4;
|
controller.$stateParams.warehouseFk = 4;
|
||||||
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('onCloneAccept()', () => {
|
describe('onCloneAccept()', () => {
|
||||||
it('should do nothing if response is not accept', () => {
|
it('should do nothing if response is not accept', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
let response = 'ERROR!';
|
let response = 'ERROR!';
|
||||||
controller.itemSelected = 'check me';
|
controller.itemSelected = 'check me';
|
||||||
|
@ -28,7 +28,7 @@ describe('Item', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do nothing if response is accept but itemSelected is not defined in the controller', () => {
|
it('should do nothing if response is accept but itemSelected is not defined in the controller', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
let response = 'accept';
|
let response = 'accept';
|
||||||
controller.itemSelected = undefined;
|
controller.itemSelected = undefined;
|
||||||
|
@ -40,7 +40,7 @@ describe('Item', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should perform a post query and then call go() then update itemSelected in the controller', () => {
|
it('should perform a post query and then call go() then update itemSelected in the controller', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
let response = 'accept';
|
let response = 'accept';
|
||||||
controller.itemSelected = {id: 1};
|
controller.itemSelected = {id: 1};
|
||||||
|
|
|
@ -46,7 +46,7 @@ describe('Item', () => {
|
||||||
describe('confirmRequest()', () => {
|
describe('confirmRequest()', () => {
|
||||||
it(`should do nothing if the request does't have itemFk or saleQuantity`, () => {
|
it(`should do nothing if the request does't have itemFk or saleQuantity`, () => {
|
||||||
let request = {};
|
let request = {};
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
controller.confirmRequest(request);
|
controller.confirmRequest(request);
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ describe('Item', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should perform a query and call vnApp.showSuccess() and refresh if the conditions are met', () => {
|
it('should perform a query and call vnApp.showSuccess() and refresh if the conditions are met', () => {
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
let model = controller.$.model;
|
let model = controller.$.model;
|
||||||
spyOn(model, 'refresh');
|
jest.spyOn(model, 'refresh');
|
||||||
|
|
||||||
const expectedResult = {concept: 'Melee Weapon'};
|
const expectedResult = {concept: 'Melee Weapon'};
|
||||||
let request = {itemFk: 1, saleQuantity: 1, id: 1};
|
let request = {itemFk: 1, saleQuantity: 1, id: 1};
|
||||||
|
@ -73,7 +73,7 @@ describe('Item', () => {
|
||||||
describe('changeQuantity()', () => {
|
describe('changeQuantity()', () => {
|
||||||
it(`should call confirmRequest() if there's no sale id in the request`, () => {
|
it(`should call confirmRequest() if there's no sale id in the request`, () => {
|
||||||
let request = {};
|
let request = {};
|
||||||
spyOn(controller, 'confirmRequest');
|
jest.spyOn(controller, 'confirmRequest');
|
||||||
|
|
||||||
controller.changeQuantity(request);
|
controller.changeQuantity(request);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
it(`should perform a query and call vnApp.showSuccess() if the conditions are met`, () => {
|
it(`should perform a query and call vnApp.showSuccess() if the conditions are met`, () => {
|
||||||
let request = {saleFk: 1, saleQuantity: 1};
|
let request = {saleFk: 1, saleQuantity: 1};
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
|
|
||||||
$httpBackend.when('PATCH', `Sales/${request.saleFk}/`).respond();
|
$httpBackend.when('PATCH', `Sales/${request.saleFk}/`).respond();
|
||||||
|
@ -114,7 +114,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('denyRequest()', () => {
|
describe('denyRequest()', () => {
|
||||||
it(`should perform a query and call vnApp.showSuccess(), refresh(), hide() and set denyObservation to null in the controller`, () => {
|
it(`should perform a query and call vnApp.showSuccess(), refresh(), hide() and set denyObservation to null in the controller`, () => {
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
const request = {id: 1};
|
const request = {id: 1};
|
||||||
const expectedResult = {isOk: false, attenderFk: 106, response: 'Denied!'};
|
const expectedResult = {isOk: false, attenderFk: 106, response: 'Denied!'};
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('$onChanges()', () => {
|
describe('$onChanges()', () => {
|
||||||
it('should call getSummary when item.id is defined', () => {
|
it('should call getSummary when item.id is defined', () => {
|
||||||
spyOn(controller, 'getSummary');
|
jest.spyOn(controller, 'getSummary');
|
||||||
controller.$onChanges();
|
controller.$onChanges();
|
||||||
|
|
||||||
expect(controller.getSummary).toHaveBeenCalledWith();
|
expect(controller.getSummary).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('itemTags setter', () => {
|
describe('itemTags setter', () => {
|
||||||
it('should call getSourceTable one time for each element in the value array', () => {
|
it('should call getSourceTable one time for each element in the value array', () => {
|
||||||
spyOn(controller, 'getSourceTable');
|
jest.spyOn(controller, 'getSourceTable');
|
||||||
let itemTags = [
|
let itemTags = [
|
||||||
{id: 1},
|
{id: 1},
|
||||||
{id: 2},
|
{id: 2},
|
||||||
|
@ -27,7 +27,7 @@ describe('Item', () => {
|
||||||
|
|
||||||
controller.itemTags = itemTags;
|
controller.itemTags = itemTags;
|
||||||
|
|
||||||
expect(controller.getSourceTable.calls.count()).toEqual(4);
|
expect(controller.getSourceTable.mock.calls.length).toEqual(4);
|
||||||
expect(controller.itemTags).toEqual(itemTags);
|
expect(controller.itemTags).toEqual(itemTags);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,8 +44,8 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('submit()', () => {
|
describe('submit()', () => {
|
||||||
it('should perform a post to update taxes', () => {
|
it('should perform a post to update taxes', () => {
|
||||||
spyOn(controller.$.watcher, 'notifySaved');
|
jest.spyOn(controller.$.watcher, 'notifySaved');
|
||||||
spyOn(controller.$.watcher, 'updateOriginalData');
|
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
||||||
controller.taxes = [
|
controller.taxes = [
|
||||||
{id: 37, countryFk: 1, taxClassFk: 1, country: {id: 1, country: 'España'}}
|
{id: 37, countryFk: 1, taxClassFk: 1, country: {id: 1, country: 'España'}}
|
||||||
];
|
];
|
||||||
|
|
|
@ -73,7 +73,7 @@ describe('Order', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call createOrder()`, () => {
|
it(`should call createOrder()`, () => {
|
||||||
spyOn(controller, 'createOrder');
|
jest.spyOn(controller, 'createOrder');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.createOrder).toHaveBeenCalledWith();
|
expect(controller.createOrder).toHaveBeenCalledWith();
|
||||||
|
@ -86,8 +86,8 @@ describe('Order', () => {
|
||||||
controller.order.addressFk = 101;
|
controller.order.addressFk = 101;
|
||||||
controller.order.agencyModeFk = 101;
|
controller.order.agencyModeFk = 101;
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
$httpBackend.when('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1);
|
$httpBackend.when('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1);
|
||||||
$httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101});
|
$httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101});
|
||||||
controller.createOrder();
|
controller.createOrder();
|
||||||
|
|
|
@ -15,14 +15,14 @@ describe('Order', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call createOrder()`, () => {
|
it(`should call createOrder()`, () => {
|
||||||
spyOn(controller.$.card, 'createOrder');
|
jest.spyOn(controller.$.card, 'createOrder');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$.card.createOrder).toHaveBeenCalledWith();
|
expect(controller.$.card.createOrder).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should call go()`, async() => {
|
it(`should call go()`, async() => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
await controller.onSubmit();
|
await controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('order.card.summary', {id: undefined});
|
expect(controller.$state.go).toHaveBeenCalledWith('order.card.summary', {id: undefined});
|
||||||
|
|
|
@ -16,8 +16,8 @@ describe('Order Component vnOrderDescriptor', () => {
|
||||||
it(`should do nothing if the response isn't accept`, () => {
|
it(`should do nothing if the response isn't accept`, () => {
|
||||||
let response = 'WAGH!';
|
let response = 'WAGH!';
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
controller.deleteOrder(response);
|
controller.deleteOrder(response);
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).not.toHaveBeenCalledWith('Order deleted!');
|
expect(controller.vnApp.showSuccess).not.toHaveBeenCalledWith('Order deleted!');
|
||||||
|
@ -27,8 +27,8 @@ describe('Order Component vnOrderDescriptor', () => {
|
||||||
it(`should perform a DELETE query if the response was accept`, () => {
|
it(`should perform a DELETE query if the response was accept`, () => {
|
||||||
let response = 'accept';
|
let response = 'accept';
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
$httpBackend.when('DELETE', `Orders/${controller.order.id}`).respond(200);
|
$httpBackend.when('DELETE', `Orders/${controller.order.id}`).respond(200);
|
||||||
$httpBackend.expect('DELETE', `Orders/${controller.order.id}`);
|
$httpBackend.expect('DELETE', `Orders/${controller.order.id}`);
|
||||||
controller.deleteOrder(response);
|
controller.deleteOrder(response);
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('Order', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('getSummary()', () => {
|
describe('getSummary()', () => {
|
||||||
it('should perform a GET query and define summary property', () => {
|
it('should now perform a GET query and define the summary property', () => {
|
||||||
let res = {id: 1, nickname: 'Batman'};
|
let res = {id: 1, nickname: 'Batman'};
|
||||||
$httpBackend.when('GET', `Orders/1/summary`).respond(200, res);
|
$httpBackend.when('GET', `Orders/1/summary`).respond(200, res);
|
||||||
$httpBackend.expect('GET', `Orders/1/summary`);
|
$httpBackend.expect('GET', `Orders/1/summary`);
|
||||||
|
|
|
@ -39,7 +39,7 @@ describe('Order', () => {
|
||||||
it('should set $scope.descriptor.itemFk, $scope.descriptor.parent and call $scope.descriptor.show()', () => {
|
it('should set $scope.descriptor.itemFk, $scope.descriptor.parent and call $scope.descriptor.show()', () => {
|
||||||
let event = {target: 1};
|
let event = {target: 1};
|
||||||
let itemFk = 1;
|
let itemFk = 1;
|
||||||
spyOn(controller.$scope.descriptor, 'show');
|
jest.spyOn(controller.$scope.descriptor, 'show');
|
||||||
controller.showDescriptor(event, itemFk);
|
controller.showDescriptor(event, itemFk);
|
||||||
|
|
||||||
expect(controller.$scope.descriptor.itemFk).toBe(1);
|
expect(controller.$scope.descriptor.itemFk).toBe(1);
|
||||||
|
@ -50,7 +50,7 @@ describe('Order', () => {
|
||||||
|
|
||||||
describe('onDescriptorLoad()', () => {
|
describe('onDescriptorLoad()', () => {
|
||||||
it('should call $scope.popover.relocate()', () => {
|
it('should call $scope.popover.relocate()', () => {
|
||||||
spyOn(controller.$scope.popover, 'relocate');
|
jest.spyOn(controller.$scope.popover, 'relocate');
|
||||||
controller.onDescriptorLoad();
|
controller.onDescriptorLoad();
|
||||||
|
|
||||||
expect(controller.$scope.popover.relocate).toHaveBeenCalledWith();
|
expect(controller.$scope.popover.relocate).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('vnRouteDescriptorPopover', () => {
|
||||||
it(`should do nothing if the received id isn't a new one`, () => {
|
it(`should do nothing if the received id isn't a new one`, () => {
|
||||||
controller.route = 'I exist!';
|
controller.route = 'I exist!';
|
||||||
controller._routeFk = 1;
|
controller._routeFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.routeFk = 1;
|
controller.routeFk = 1;
|
||||||
|
|
||||||
expect(controller.route).toEqual('I exist!');
|
expect(controller.route).toEqual('I exist!');
|
||||||
|
@ -33,7 +33,7 @@ describe('vnRouteDescriptorPopover', () => {
|
||||||
it(`should set the received id, set the route null and then call getCard()`, () => {
|
it(`should set the received id, set the route null and then call getCard()`, () => {
|
||||||
controller.route = `Please don't`;
|
controller.route = `Please don't`;
|
||||||
controller._routeFk = 1;
|
controller._routeFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.routeFk = 999;
|
controller.routeFk = 999;
|
||||||
|
|
||||||
expect(controller.route).toBeNull();
|
expect(controller.route).toBeNull();
|
||||||
|
@ -44,7 +44,7 @@ describe('vnRouteDescriptorPopover', () => {
|
||||||
|
|
||||||
describe('route()', () => {
|
describe('route()', () => {
|
||||||
it(`should save the client on the controller and then call relocate()`, () => {
|
it(`should save the client on the controller and then call relocate()`, () => {
|
||||||
spyOn(controller.$.popover, 'relocate');
|
jest.spyOn(controller.$.popover, 'relocate');
|
||||||
let route = `i'm the route!`;
|
let route = `i'm the route!`;
|
||||||
controller.route = route;
|
controller.route = route;
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
@ -56,7 +56,7 @@ describe('vnRouteDescriptorPopover', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should call the popover show() method`, () => {
|
it(`should call the popover show() method`, () => {
|
||||||
spyOn(controller.$.popover, 'show');
|
jest.spyOn(controller.$.popover, 'show');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -87,8 +87,8 @@ describe('Route', () => {
|
||||||
describe('setPriority()', () => {
|
describe('setPriority()', () => {
|
||||||
it('should set a ticket priority', () => {
|
it('should set a ticket priority', () => {
|
||||||
controller.$.model = {refresh: () => {}};
|
controller.$.model = {refresh: () => {}};
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
const ticketId = 1;
|
const ticketId = 1;
|
||||||
const priority = 999;
|
const priority = 999;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ describe('Route', () => {
|
||||||
|
|
||||||
describe('goToBuscaman()', () => {
|
describe('goToBuscaman()', () => {
|
||||||
it('should open buscaman with the given arguments', () => {
|
it('should open buscaman with the given arguments', () => {
|
||||||
spyOn(window, 'open');
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
const expectedUrl = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=46460 Av Espioca 100+to:n19 London my street';
|
const expectedUrl = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=46460 Av Espioca 100+to:n19 London my street';
|
||||||
controller.route = {vehicleFk: 1};
|
controller.route = {vehicleFk: 1};
|
||||||
const url = `Routes/${controller.route.vehicleFk}/getDeliveryPoint`;
|
const url = `Routes/${controller.route.vehicleFk}/getDeliveryPoint`;
|
||||||
|
@ -147,7 +147,7 @@ describe('Route', () => {
|
||||||
describe('showDeleteConfirm()', () => {
|
describe('showDeleteConfirm()', () => {
|
||||||
it('should open a confirm dialog after setting the selected ticket into the controller', () => {
|
it('should open a confirm dialog after setting the selected ticket into the controller', () => {
|
||||||
controller.$.confirm = {show: () => {}};
|
controller.$.confirm = {show: () => {}};
|
||||||
spyOn(controller.$.confirm, 'show');
|
jest.spyOn(controller.$.confirm, 'show');
|
||||||
let ticketId = 1;
|
let ticketId = 1;
|
||||||
|
|
||||||
controller.showDeleteConfirm(ticketId);
|
controller.showDeleteConfirm(ticketId);
|
||||||
|
@ -159,8 +159,8 @@ describe('Route', () => {
|
||||||
|
|
||||||
describe('removeTicketFromRoute()', () => {
|
describe('removeTicketFromRoute()', () => {
|
||||||
it('should perform a patch query then call showSuccess and updateVolume methods', () => {
|
it('should perform a patch query then call showSuccess and updateVolume methods', () => {
|
||||||
spyOn(controller, 'updateVolume');
|
jest.spyOn(controller, 'updateVolume').mockReturnThis();
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
let ticketId = 1;
|
let ticketId = 1;
|
||||||
controller.selectedTicket = ticketId;
|
controller.selectedTicket = ticketId;
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ describe('Route', () => {
|
||||||
controller.$.model = {refresh: () => {}};
|
controller.$.model = {refresh: () => {}};
|
||||||
controller.card = {reload: () => {}};
|
controller.card = {reload: () => {}};
|
||||||
controller.$stateParamds = {id: 999};
|
controller.$stateParamds = {id: 999};
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
spyOn(controller.card, 'reload');
|
jest.spyOn(controller.card, 'reload');
|
||||||
|
|
||||||
let ticketId = 1;
|
let ticketId = 1;
|
||||||
controller.selectedTicket = ticketId;
|
controller.selectedTicket = ticketId;
|
||||||
|
@ -197,8 +197,8 @@ describe('Route', () => {
|
||||||
describe('guessPriority()', () => {
|
describe('guessPriority()', () => {
|
||||||
it('should perform a GET query then call both refresh and showSuccess methods', () => {
|
it('should perform a GET query then call both refresh and showSuccess methods', () => {
|
||||||
controller.$.model = {refresh: () => {}};
|
controller.$.model = {refresh: () => {}};
|
||||||
spyOn(controller.$.model, 'refresh');
|
jest.spyOn(controller.$.model, 'refresh');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
controller.$stateParams = {id: 99};
|
controller.$stateParams = {id: 99};
|
||||||
|
|
||||||
const url = `Routes/${controller.$stateParams.id}/guessPriority/`;
|
const url = `Routes/${controller.$stateParams.id}/guessPriority/`;
|
||||||
|
@ -214,9 +214,9 @@ describe('Route', () => {
|
||||||
describe('showTicketDescriptor()', () => {
|
describe('showTicketDescriptor()', () => {
|
||||||
it('should call the descriptor show function after setting the parent and the ticket id', () => {
|
it('should call the descriptor show function after setting the parent and the ticket id', () => {
|
||||||
controller.$.ticketDescriptor = {show: () => {}};
|
controller.$.ticketDescriptor = {show: () => {}};
|
||||||
spyOn(controller.$.ticketDescriptor, 'show');
|
jest.spyOn(controller.$.ticketDescriptor, 'show');
|
||||||
const event = {target: {}, preventDefault: () => {}};
|
const event = {target: {}, preventDefault: () => {}};
|
||||||
spyOn(event, 'preventDefault');
|
jest.spyOn(event, 'preventDefault');
|
||||||
const ticketId = 999;
|
const ticketId = 999;
|
||||||
controller.showTicketDescriptor(event, ticketId);
|
controller.showTicketDescriptor(event, ticketId);
|
||||||
|
|
||||||
|
@ -229,9 +229,9 @@ describe('Route', () => {
|
||||||
describe('showClientDescriptor()', () => {
|
describe('showClientDescriptor()', () => {
|
||||||
it('should call the descriptor show method after setting the parent and the client id', () => {
|
it('should call the descriptor show method after setting the parent and the client id', () => {
|
||||||
controller.$.clientDescriptor = {show: () => {}};
|
controller.$.clientDescriptor = {show: () => {}};
|
||||||
spyOn(controller.$.clientDescriptor, 'show');
|
jest.spyOn(controller.$.clientDescriptor, 'show');
|
||||||
const event = {target: {}, preventDefault: () => {}};
|
const event = {target: {}, preventDefault: () => {}};
|
||||||
spyOn(event, 'preventDefault');
|
jest.spyOn(event, 'preventDefault');
|
||||||
const clientId = 999;
|
const clientId = 999;
|
||||||
controller.showClientDescriptor(event, clientId);
|
controller.showClientDescriptor(event, clientId);
|
||||||
|
|
||||||
|
@ -244,9 +244,9 @@ describe('Route', () => {
|
||||||
describe('openPossibleTicketsDialog()', () => {
|
describe('openPossibleTicketsDialog()', () => {
|
||||||
it('should call both refresh and show methods in posible tickets model and dialog', () => {
|
it('should call both refresh and show methods in posible tickets model and dialog', () => {
|
||||||
controller.$.possibleTicketsModel = {refresh: () => {}};
|
controller.$.possibleTicketsModel = {refresh: () => {}};
|
||||||
spyOn(controller.$.possibleTicketsModel, 'refresh');
|
jest.spyOn(controller.$.possibleTicketsModel, 'refresh');
|
||||||
controller.$.possibleTicketsDialog = {show: () => {}};
|
controller.$.possibleTicketsDialog = {show: () => {}};
|
||||||
spyOn(controller.$.possibleTicketsDialog, 'show');
|
jest.spyOn(controller.$.possibleTicketsDialog, 'show');
|
||||||
|
|
||||||
controller.openPossibleTicketsDialog();
|
controller.openPossibleTicketsDialog();
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ describe('Route', () => {
|
||||||
describe('setTicketsRoute()', () => {
|
describe('setTicketsRoute()', () => {
|
||||||
it('should perform a POST query to add tickets to the route', done => {
|
it('should perform a POST query to add tickets to the route', done => {
|
||||||
controller.$.possibleTicketsModel = {save: () => {}};
|
controller.$.possibleTicketsModel = {save: () => {}};
|
||||||
spyOn(controller.$.possibleTicketsModel, 'save').and.returnValue(Promise.resolve());
|
jest.spyOn(controller.$.possibleTicketsModel, 'save').mockReturnValue(Promise.resolve());
|
||||||
controller.$.model = {data: [
|
controller.$.model = {data: [
|
||||||
{id: 1, checked: false}
|
{id: 1, checked: false}
|
||||||
]};
|
]};
|
||||||
|
|
|
@ -23,14 +23,14 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('ticket() setter', () => {
|
describe('ticket() setter', () => {
|
||||||
it('should set ticket property and call onChangeClient() method', () => {
|
it('should set ticket property and call onChangeClient() method', () => {
|
||||||
spyOn(controller, 'onChangeClient');
|
jest.spyOn(controller, 'onChangeClient');
|
||||||
controller.ticket = {id: 1, clientFk: 101};
|
controller.ticket = {id: 1, clientFk: 101};
|
||||||
|
|
||||||
expect(controller.onChangeClient).toHaveBeenCalledWith(101);
|
expect(controller.onChangeClient).toHaveBeenCalledWith(101);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should not call onChangeClient() method as the ticket doesn't have an ID`, () => {
|
it(`should not call onChangeClient() method as the ticket doesn't have an ID`, () => {
|
||||||
spyOn(controller, 'onChangeClient');
|
jest.spyOn(controller, 'onChangeClient');
|
||||||
controller.ticket = {};
|
controller.ticket = {};
|
||||||
|
|
||||||
expect(controller.onChangeClient).not.toHaveBeenCalledWith();
|
expect(controller.onChangeClient).not.toHaveBeenCalledWith();
|
||||||
|
@ -47,7 +47,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('clientId() setter', () => {
|
describe('clientId() setter', () => {
|
||||||
it('should set clientId property and call onChangeClient() method ', () => {
|
it('should set clientId property and call onChangeClient() method ', () => {
|
||||||
spyOn(controller, 'onChangeClient');
|
jest.spyOn(controller, 'onChangeClient');
|
||||||
controller.ticket = {id: 1, clientId: 101};
|
controller.ticket = {id: 1, clientId: 101};
|
||||||
controller.clientId = 102;
|
controller.clientId = 102;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('addressId() setter', () => {
|
describe('addressId() setter', () => {
|
||||||
it('should set addressId property and call getShipped() method ', () => {
|
it('should set addressId property and call getShipped() method ', () => {
|
||||||
spyOn(controller, 'getShipped');
|
jest.spyOn(controller, 'getShipped');
|
||||||
controller.ticket.addressFk = 99;
|
controller.ticket.addressFk = 99;
|
||||||
controller.addressId = 100;
|
controller.addressId = 100;
|
||||||
const landed = new Date();
|
const landed = new Date();
|
||||||
|
@ -92,7 +92,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('warehouseId() setter', () => {
|
describe('warehouseId() setter', () => {
|
||||||
it('should set warehouseId property and call getShipped() method ', () => {
|
it('should set warehouseId property and call getShipped() method ', () => {
|
||||||
spyOn(controller, 'getShipped');
|
jest.spyOn(controller, 'getShipped');
|
||||||
controller.ticket.warehouseId = 1;
|
controller.ticket.warehouseId = 1;
|
||||||
controller.warehouseId = 2;
|
controller.warehouseId = 2;
|
||||||
const landed = new Date();
|
const landed = new Date();
|
||||||
|
@ -120,7 +120,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('shipped() setter', () => {
|
describe('shipped() setter', () => {
|
||||||
it('should set shipped property and call getLanded() method ', () => {
|
it('should set shipped property and call getLanded() method ', () => {
|
||||||
spyOn(controller, 'getLanded');
|
jest.spyOn(controller, 'getLanded');
|
||||||
const shipped = new Date();
|
const shipped = new Date();
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
shipped: shipped,
|
shipped: shipped,
|
||||||
|
@ -145,7 +145,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('landed() setter', () => {
|
describe('landed() setter', () => {
|
||||||
it('should set shipped property and call getShipped() method ', () => {
|
it('should set shipped property and call getShipped() method ', () => {
|
||||||
spyOn(controller, 'getShipped');
|
jest.spyOn(controller, 'getShipped');
|
||||||
const landed = new Date();
|
const landed = new Date();
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
landed: landed,
|
landed: landed,
|
||||||
|
@ -170,7 +170,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('agencyModeId() setter', () => {
|
describe('agencyModeId() setter', () => {
|
||||||
it('should set agencyModeId property and call getLanded() method', () => {
|
it('should set agencyModeId property and call getLanded() method', () => {
|
||||||
spyOn(controller, 'getLanded');
|
jest.spyOn(controller, 'getLanded');
|
||||||
const shipped = new Date();
|
const shipped = new Date();
|
||||||
const agencyModeId = 8;
|
const agencyModeId = 8;
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
|
@ -186,7 +186,7 @@ describe('Ticket', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do nothing if attempting to set the same agencyMode id', () => {
|
it('should do nothing if attempting to set the same agencyMode id', () => {
|
||||||
spyOn(controller, 'getShipped');
|
jest.spyOn(controller, 'getShipped');
|
||||||
const landed = new Date();
|
const landed = new Date();
|
||||||
const agencyModeId = 7;
|
const agencyModeId = 7;
|
||||||
const expectedResult = {
|
const expectedResult = {
|
||||||
|
@ -213,7 +213,7 @@ describe('Ticket', () => {
|
||||||
describe('zoneId() setter', () => {
|
describe('zoneId() setter', () => {
|
||||||
it('should set zoneId property and call onChangeZone() method ', () => {
|
it('should set zoneId property and call onChangeZone() method ', () => {
|
||||||
const zoneId = 5;
|
const zoneId = 5;
|
||||||
spyOn(controller, 'onChangeZone');
|
jest.spyOn(controller, 'onChangeZone');
|
||||||
controller.ticket = {id: 1};
|
controller.ticket = {id: 1};
|
||||||
controller.zoneId = 5;
|
controller.zoneId = 5;
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
it('should do nothing if attempting to set the same zone id', () => {
|
it('should do nothing if attempting to set the same zone id', () => {
|
||||||
const zoneId = 5;
|
const zoneId = 5;
|
||||||
spyOn(controller, 'onChangeZone');
|
jest.spyOn(controller, 'onChangeZone');
|
||||||
controller.ticket = {id: 1, zoneFk: zoneId};
|
controller.ticket = {id: 1, zoneFk: zoneId};
|
||||||
controller.zoneId = zoneId;
|
controller.zoneId = zoneId;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('ticket Component vnTicketDescriptorPopover', () => {
|
||||||
it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => {
|
it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => {
|
||||||
controller.ticket = 'I exist!';
|
controller.ticket = 'I exist!';
|
||||||
controller._ticketFk = 1;
|
controller._ticketFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.ticketFk = 1;
|
controller.ticketFk = 1;
|
||||||
|
|
||||||
expect(controller.ticket).toEqual('I exist!');
|
expect(controller.ticket).toEqual('I exist!');
|
||||||
|
@ -33,7 +33,7 @@ describe('ticket Component vnTicketDescriptorPopover', () => {
|
||||||
it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => {
|
it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => {
|
||||||
controller.ticket = `Please don't`;
|
controller.ticket = `Please don't`;
|
||||||
controller._ticketFk = 1;
|
controller._ticketFk = 1;
|
||||||
spyOn(controller, 'getCard');
|
jest.spyOn(controller, 'getCard');
|
||||||
controller.ticketFk = 999;
|
controller.ticketFk = 999;
|
||||||
|
|
||||||
expect(controller.ticket).toBeNull();
|
expect(controller.ticket).toBeNull();
|
||||||
|
@ -44,7 +44,7 @@ describe('ticket Component vnTicketDescriptorPopover', () => {
|
||||||
|
|
||||||
describe('ticket()', () => {
|
describe('ticket()', () => {
|
||||||
it(`should save the ticket into _ticket and then call relocate()`, () => {
|
it(`should save the ticket into _ticket and then call relocate()`, () => {
|
||||||
spyOn(controller.$.popover, 'relocate');
|
jest.spyOn(controller.$.popover, 'relocate');
|
||||||
controller.ticket = `i'm the ticket!`;
|
controller.ticket = `i'm the ticket!`;
|
||||||
$timeout.flush();
|
$timeout.flush();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ describe('ticket Component vnTicketDescriptorPopover', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should call the show()`, () => {
|
it(`should call the show()`, () => {
|
||||||
spyOn(controller.$.popover, 'show');
|
jest.spyOn(controller.$.popover, 'show');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
describe('showAddTurnDialog()', () => {
|
describe('showAddTurnDialog()', () => {
|
||||||
it('should call controller.$.addTurn.show()', () => {
|
it('should call controller.$.addTurn.show()', () => {
|
||||||
controller.$.addTurn = {show: () => {}};
|
controller.$.addTurn = {show: () => {}};
|
||||||
spyOn(controller.$.addTurn, 'show');
|
jest.spyOn(controller.$.addTurn, 'show');
|
||||||
controller.showAddTurnDialog();
|
controller.showAddTurnDialog();
|
||||||
|
|
||||||
expect(controller.$.addTurn.show).toHaveBeenCalledWith();
|
expect(controller.$.addTurn.show).toHaveBeenCalledWith();
|
||||||
|
@ -39,7 +39,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
describe('addTurn()', () => {
|
describe('addTurn()', () => {
|
||||||
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
|
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
|
||||||
controller.$.addTurn = {hide: () => {}};
|
controller.$.addTurn = {hide: () => {}};
|
||||||
spyOn(controller.$.addTurn, 'hide');
|
jest.spyOn(controller.$.addTurn, 'hide');
|
||||||
|
|
||||||
$httpBackend.expectPATCH(`TicketWeeklies`).respond();
|
$httpBackend.expectPATCH(`TicketWeeklies`).respond();
|
||||||
controller.addTurn(1);
|
controller.addTurn(1);
|
||||||
|
@ -52,7 +52,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
describe('showDeleteTicketDialog()', () => {
|
describe('showDeleteTicketDialog()', () => {
|
||||||
it('should call vnApp.showError() if the ticket isnt editable', () => {
|
it('should call vnApp.showError() if the ticket isnt editable', () => {
|
||||||
controller.ticket.tracking = {state: {alertLevel: 3}};
|
controller.ticket.tracking = {state: {alertLevel: 3}};
|
||||||
spyOn(controller.vnApp, 'showError');
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
controller.showDeleteTicketDialog();
|
controller.showDeleteTicketDialog();
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('This ticket cant be deleted');
|
expect(controller.vnApp.showError).toHaveBeenCalledWith('This ticket cant be deleted');
|
||||||
|
@ -61,7 +61,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
it('should call deleteConfirmation.show() if the ticket is editable', () => {
|
it('should call deleteConfirmation.show() if the ticket is editable', () => {
|
||||||
controller.ticket.tracking = {state: {alertLevel: 0}};
|
controller.ticket.tracking = {state: {alertLevel: 0}};
|
||||||
controller.$.deleteConfirmation = {show: () => {}};
|
controller.$.deleteConfirmation = {show: () => {}};
|
||||||
spyOn(controller.$.deleteConfirmation, 'show');
|
jest.spyOn(controller.$.deleteConfirmation, 'show');
|
||||||
controller.showDeleteTicketDialog();
|
controller.showDeleteTicketDialog();
|
||||||
|
|
||||||
expect(controller.$.deleteConfirmation.show).toHaveBeenCalledWith();
|
expect(controller.$.deleteConfirmation.show).toHaveBeenCalledWith();
|
||||||
|
@ -70,8 +70,8 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
|
|
||||||
describe('deleteTicket()', () => {
|
describe('deleteTicket()', () => {
|
||||||
it('should make a query and call vnApp.showSuccess() if the response is accept', () => {
|
it('should make a query and call vnApp.showSuccess() if the response is accept', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go').mockReturnValue('ok');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
$httpBackend.expectPOST(`Tickets/2/setDeleted`).respond();
|
$httpBackend.expectPOST(`Tickets/2/setDeleted`).respond();
|
||||||
controller.deleteTicket('accept');
|
controller.deleteTicket('accept');
|
||||||
|
@ -90,7 +90,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
};
|
};
|
||||||
const serializedParams = $httpParamSerializer(params);
|
const serializedParams = $httpParamSerializer(params);
|
||||||
let expectedPath = `api/report/delivery-note?${serializedParams}`;
|
let expectedPath = `api/report/delivery-note?${serializedParams}`;
|
||||||
spyOn(window, 'open');
|
jest.spyOn(window, 'open').mockReturnThis();
|
||||||
controller.showDeliveryNote();
|
controller.showDeliveryNote();
|
||||||
|
|
||||||
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
||||||
|
@ -99,7 +99,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
|
|
||||||
describe('sendDeliveryNote()', () => {
|
describe('sendDeliveryNote()', () => {
|
||||||
it('should make a query and call vnApp.showMessage()', () => {
|
it('should make a query and call vnApp.showMessage()', () => {
|
||||||
spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
recipient: 'client@email',
|
recipient: 'client@email',
|
||||||
|
@ -119,8 +119,8 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
|
|
||||||
describe('makeInvoice()', () => {
|
describe('makeInvoice()', () => {
|
||||||
it('should make a query and call $state.reload() method if the response is accept', () => {
|
it('should make a query and call $state.reload() method if the response is accept', () => {
|
||||||
spyOn(controller.$state, 'reload');
|
jest.spyOn(controller.$state, 'reload').mockReturnThis();
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
$httpBackend.when('POST', 'Tickets/2/makeInvoice').respond();
|
$httpBackend.when('POST', 'Tickets/2/makeInvoice').respond();
|
||||||
$httpBackend.expect('POST', 'Tickets/2/makeInvoice').respond();
|
$httpBackend.expect('POST', 'Tickets/2/makeInvoice').respond();
|
||||||
|
@ -134,7 +134,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
|
|
||||||
describe('regenerateInvoice()', () => {
|
describe('regenerateInvoice()', () => {
|
||||||
it('should make a query and show a success snackbar if the response is accept', () => {
|
it('should make a query and show a success snackbar if the response is accept', () => {
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
$httpBackend.when('POST', 'InvoiceOuts/1/regenerate').respond();
|
$httpBackend.when('POST', 'InvoiceOuts/1/regenerate').respond();
|
||||||
$httpBackend.expect('POST', 'InvoiceOuts/1/regenerate').respond();
|
$httpBackend.expect('POST', 'InvoiceOuts/1/regenerate').respond();
|
||||||
|
@ -148,8 +148,8 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
describe('changeShipped()', () => {
|
describe('changeShipped()', () => {
|
||||||
it('should make a query and change the shipped hour if the response is accept', () => {
|
it('should make a query and change the shipped hour if the response is accept', () => {
|
||||||
controller.ticket.id = 12;
|
controller.ticket.id = 12;
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller, 'cardReload');
|
jest.spyOn(controller, 'cardReload');
|
||||||
|
|
||||||
$httpBackend.when('POST', 'Tickets/12/updateEditableTicket').respond();
|
$httpBackend.when('POST', 'Tickets/12/updateEditableTicket').respond();
|
||||||
$httpBackend.expect('POST', 'Tickets/12/updateEditableTicket').respond();
|
$httpBackend.expect('POST', 'Tickets/12/updateEditableTicket').respond();
|
||||||
|
@ -185,7 +185,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
describe('canStowaway()', () => {
|
describe('canStowaway()', () => {
|
||||||
it('should make a query and return if the ticket can be stowawayed', () => {
|
it('should make a query and return if the ticket can be stowawayed', () => {
|
||||||
controller.ticket.id = 16;
|
controller.ticket.id = 16;
|
||||||
spyOn(controller, 'isTicketModule').and.callThrough();
|
jest.spyOn(controller, 'isTicketModule');
|
||||||
$httpBackend.when('GET', 'Tickets/16/canHaveStowaway').respond(true);
|
$httpBackend.when('GET', 'Tickets/16/canHaveStowaway').respond(true);
|
||||||
$httpBackend.expect('GET', 'Tickets/16/canHaveStowaway').respond(true);
|
$httpBackend.expect('GET', 'Tickets/16/canHaveStowaway').respond(true);
|
||||||
controller.canStowaway();
|
controller.canStowaway();
|
||||||
|
@ -203,7 +203,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
{state: {name: 'client'}}
|
{state: {name: 'client'}}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
spyOn(controller, 'isTicketModule').and.callThrough();
|
jest.spyOn(controller, 'isTicketModule');
|
||||||
controller.canStowaway();
|
controller.canStowaway();
|
||||||
|
|
||||||
expect(controller.canShowStowaway).toBeUndefined();
|
expect(controller.canShowStowaway).toBeUndefined();
|
||||||
|
@ -213,7 +213,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
||||||
|
|
||||||
describe('recalculateComponents()', () => {
|
describe('recalculateComponents()', () => {
|
||||||
it('should make a query and show a success snackbar', () => {
|
it('should make a query and show a success snackbar', () => {
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
|
||||||
$httpBackend.when('POST', 'Tickets/2/recalculateComponents').respond();
|
$httpBackend.when('POST', 'Tickets/2/recalculateComponents').respond();
|
||||||
$httpBackend.expect('POST', 'Tickets/2/recalculateComponents').respond();
|
$httpBackend.expect('POST', 'Tickets/2/recalculateComponents').respond();
|
||||||
|
|
|
@ -24,8 +24,8 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('client() setter', () => {
|
describe('client() setter', () => {
|
||||||
it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
jest.spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller.ticket = {
|
controller.ticket = {
|
||||||
id: 15,
|
id: 15,
|
||||||
name: 'Bruce wayne'
|
name: 'Bruce wayne'
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('ticket() setter', () => {
|
describe('ticket() setter', () => {
|
||||||
it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
jest.spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller._ticket = undefined;
|
controller._ticket = undefined;
|
||||||
controller.ticket = {
|
controller.ticket = {
|
||||||
id: 15
|
id: 15
|
||||||
|
|
|
@ -22,8 +22,8 @@ describe('Ticket', () => {
|
||||||
it('should make an HTTP Post query', () => {
|
it('should make an HTTP Post query', () => {
|
||||||
const dmsId = 1;
|
const dmsId = 1;
|
||||||
const dmsIndex = 0;
|
const dmsIndex = 0;
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
controller.ticketDms = [{dmsFk: 1}];
|
controller.ticketDms = [{dmsFk: 1}];
|
||||||
controller.dmsIndex = dmsIndex;
|
controller.dmsIndex = dmsIndex;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('returnDialog()', () => {
|
describe('returnDialog()', () => {
|
||||||
it('should perform a DELETE query', () => {
|
it('should perform a DELETE query', () => {
|
||||||
spyOn($scope.model, 'refresh');
|
jest.spyOn($scope.model, 'refresh');
|
||||||
|
|
||||||
let response = 'accept';
|
let response = 'accept';
|
||||||
controller.expeditionId = 1;
|
controller.expeditionId = 1;
|
||||||
|
|
|
@ -69,7 +69,7 @@ describe('Component vnTicketIndex', () => {
|
||||||
describe('preview()', () => {
|
describe('preview()', () => {
|
||||||
it('should show the dialog summary', () => {
|
it('should show the dialog summary', () => {
|
||||||
controller.$.summary = {show: () => {}};
|
controller.$.summary = {show: () => {}};
|
||||||
spyOn(controller.$.summary, 'show');
|
jest.spyOn(controller.$.summary, 'show');
|
||||||
|
|
||||||
let event = new MouseEvent('click', {
|
let event = new MouseEvent('click', {
|
||||||
view: $window,
|
view: $window,
|
||||||
|
|
|
@ -206,7 +206,7 @@ class Controller {
|
||||||
|
|
||||||
onStateChange(value) {
|
onStateChange(value) {
|
||||||
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
let params = {ticketFk: this.$state.params.id, stateFk: value};
|
||||||
this.$http.post(`TicketTrackings/changeState`, params).then(() => {
|
this.$http.post('TicketTrackings/changeState', params).then(() => {
|
||||||
this.card.reload();
|
this.card.reload();
|
||||||
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('edit() setter', () => {
|
describe('edit() setter', () => {
|
||||||
it('should set _edit value and call setNewDiscount', () => {
|
it('should set _edit value and call setNewDiscount', () => {
|
||||||
spyOn(controller, 'setNewDiscount');
|
jest.spyOn(controller, 'setNewDiscount');
|
||||||
controller.edit = {id: 1};
|
controller.edit = {id: 1};
|
||||||
|
|
||||||
expect(controller.edit).toEqual({id: 1});
|
expect(controller.edit).toEqual({id: 1});
|
||||||
|
@ -36,7 +36,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('bulk() setter', () => {
|
describe('bulk() setter', () => {
|
||||||
it('should set _bulk value and call setNewDiscount', () => {
|
it('should set _bulk value and call setNewDiscount', () => {
|
||||||
spyOn(controller, 'setNewDiscount');
|
jest.spyOn(controller, 'setNewDiscount');
|
||||||
controller.bulk = true;
|
controller.bulk = true;
|
||||||
|
|
||||||
expect(controller.bulk).toEqual(true);
|
expect(controller.bulk).toEqual(true);
|
||||||
|
@ -68,7 +68,7 @@ describe('Ticket', () => {
|
||||||
controller.bulk = false;
|
controller.bulk = false;
|
||||||
controller.newDiscount = 15;
|
controller.newDiscount = 15;
|
||||||
controller.edit = [{discount: 15}];
|
controller.edit = [{discount: 15}];
|
||||||
spyOn(controller.vnApp, 'showError');
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
controller.updateDiscount();
|
controller.updateDiscount();
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith('There are no changes to save');
|
expect(controller.vnApp.showError).toHaveBeenCalledWith('There are no changes to save');
|
||||||
|
|
|
@ -61,7 +61,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('createClaim()', () => {
|
describe('createClaim()', () => {
|
||||||
it('should perform a query and call windows open', () => {
|
it('should perform a query and call windows open', () => {
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
const claim = {id: 1};
|
const claim = {id: 1};
|
||||||
const sales = [{id: 1}, {id: 2}];
|
const sales = [{id: 1}, {id: 2}];
|
||||||
|
@ -110,7 +110,7 @@ describe('Ticket', () => {
|
||||||
let filter = {where: {code: 'OK'}, fields: ['id']};
|
let filter = {where: {code: 'OK'}, fields: ['id']};
|
||||||
filter = encodeURIComponent(JSON.stringify(filter));
|
filter = encodeURIComponent(JSON.stringify(filter));
|
||||||
let res = [{id: 3}];
|
let res = [{id: 3}];
|
||||||
spyOn(controller, 'onStateChange');
|
jest.spyOn(controller, 'onStateChange').mockReturnThis();
|
||||||
|
|
||||||
$httpBackend.whenGET(`States?filter=${filter}`).respond(res);
|
$httpBackend.whenGET(`States?filter=${filter}`).respond(res);
|
||||||
$httpBackend.expectGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
$httpBackend.expectGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
||||||
|
@ -151,7 +151,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('unmarkAsReserved()', () => {
|
describe('unmarkAsReserved()', () => {
|
||||||
it('should call setReserved with false', () => {
|
it('should call setReserved with false', () => {
|
||||||
spyOn(controller, 'setReserved');
|
jest.spyOn(controller, 'setReserved');
|
||||||
|
|
||||||
controller.unmarkAsReserved(false);
|
controller.unmarkAsReserved(false);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('markAsReserved()', () => {
|
describe('markAsReserved()', () => {
|
||||||
it('should call setReserved with true', () => {
|
it('should call setReserved with true', () => {
|
||||||
spyOn(controller, 'setReserved');
|
jest.spyOn(controller, 'setReserved');
|
||||||
|
|
||||||
controller.markAsReserved(true);
|
controller.markAsReserved(true);
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('showSMSDialog()', () => {
|
describe('showSMSDialog()', () => {
|
||||||
it('should open an SMS dialog with specified data', () => {
|
it('should open an SMS dialog with specified data', () => {
|
||||||
spyOn(controller.$scope.sms, 'open');
|
jest.spyOn(controller.$scope.sms, 'open');
|
||||||
|
|
||||||
controller.sales[0].checked = true;
|
controller.sales[0].checked = true;
|
||||||
controller.showSMSDialog();
|
controller.showSMSDialog();
|
||||||
|
@ -203,7 +203,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('updateQuantity()', () => {
|
describe('updateQuantity()', () => {
|
||||||
it('should make a POST query saving sale quantity', () => {
|
it('should make a POST query saving sale quantity', () => {
|
||||||
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
jest.spyOn(controller.$scope.watcher, 'updateOriginalData');
|
||||||
const data = {quantity: 10};
|
const data = {quantity: 10};
|
||||||
const sale = sales[0];
|
const sale = sales[0];
|
||||||
sale.quantity = 10;
|
sale.quantity = 10;
|
||||||
|
@ -222,7 +222,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('updateConcept()', () => {
|
describe('updateConcept()', () => {
|
||||||
it('should make a POST query saving sale concept', () => {
|
it('should make a POST query saving sale concept', () => {
|
||||||
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
jest.spyOn(controller.$scope.watcher, 'updateOriginalData');
|
||||||
const data = {newConcept: 'My new weapon'};
|
const data = {newConcept: 'My new weapon'};
|
||||||
const sale = sales[0];
|
const sale = sales[0];
|
||||||
sale.concept = 'My new weapon';
|
sale.concept = 'My new weapon';
|
||||||
|
@ -241,7 +241,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('addSale()', () => {
|
describe('addSale()', () => {
|
||||||
it('should make a POST query adding a new sale', () => {
|
it('should make a POST query adding a new sale', () => {
|
||||||
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
jest.spyOn(controller.$scope.watcher, 'updateOriginalData');
|
||||||
const newSale = {itemFk: 4, quantity: 10};
|
const newSale = {itemFk: 4, quantity: 10};
|
||||||
const params = {itemId: 4, quantity: 10};
|
const params = {itemId: 4, quantity: 10};
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('transferSales()', () => {
|
describe('transferSales()', () => {
|
||||||
it('should transfer sales to a ticket', () => {
|
it('should transfer sales to a ticket', () => {
|
||||||
spyOn(controller, 'goToTicket');
|
jest.spyOn(controller, 'goToTicket');
|
||||||
controller.transfer = {
|
controller.transfer = {
|
||||||
sales: [{id: 1, itemFk: 1}, {id: 2, itemFk: 4}]
|
sales: [{id: 1, itemFk: 1}, {id: 2, itemFk: 4}]
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe('Ticket', () => {
|
||||||
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||||
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
$httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params);
|
$httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params);
|
||||||
|
|
||||||
controller.onResponse('accept');
|
controller.onResponse('accept');
|
||||||
|
@ -38,7 +38,7 @@ describe('Ticket', () => {
|
||||||
it('should call onResponse without the destination and show an error snackbar', () => {
|
it('should call onResponse without the destination and show an error snackbar', () => {
|
||||||
controller.sms = {destinationFk: 101, message: 'My SMS'};
|
controller.sms = {destinationFk: 101, message: 'My SMS'};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showError');
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
controller.onResponse('accept');
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ describe('Ticket', () => {
|
||||||
it('should call onResponse without the message and show an error snackbar', () => {
|
it('should call onResponse without the message and show an error snackbar', () => {
|
||||||
controller.sms = {destinationFk: 101, destination: 222222222};
|
controller.sms = {destinationFk: 101, destination: 222222222};
|
||||||
|
|
||||||
spyOn(controller.vnApp, 'showError');
|
jest.spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
controller.onResponse('accept');
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('Ticket', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('ticket()', () => {
|
describe('ticket()', () => {
|
||||||
it('should perform a GET query and define summary property', () => {
|
it('should perform a GET query and define the summary property', () => {
|
||||||
let res = {id: 1, nickname: 'Batman'};
|
let res = {id: 1, nickname: 'Batman'};
|
||||||
$httpBackend.when('GET', `Tickets/1/summary`).respond(200, res);
|
$httpBackend.when('GET', `Tickets/1/summary`).respond(200, res);
|
||||||
$httpBackend.expect('GET', `Tickets/1/summary`);
|
$httpBackend.expect('GET', `Tickets/1/summary`);
|
||||||
|
|
|
@ -55,10 +55,10 @@ describe('Ticket', () => {
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should POST the data, call updateOriginalData, reload, showSuccess and go functions', () => {
|
it('should POST the data, call updateOriginalData, reload, showSuccess and go functions', () => {
|
||||||
controller.params = {stateFk: 22, workerFk: 101};
|
controller.params = {stateFk: 22, workerFk: 101};
|
||||||
spyOn(controller.card, 'reload');
|
jest.spyOn(controller.card, 'reload');
|
||||||
spyOn(controller.$.watcher, 'updateOriginalData');
|
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$state, 'go');
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
$httpBackend.expectPOST(`TicketTrackings/changeState`, controller.params).respond({});
|
$httpBackend.expectPOST(`TicketTrackings/changeState`, controller.params).respond({});
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe('ticket', () => {
|
||||||
|
|
||||||
describe('sales() setter', () => {
|
describe('sales() setter', () => {
|
||||||
it('should set sales property on controller an then call applyVolumes() method', () => {
|
it('should set sales property on controller an then call applyVolumes() method', () => {
|
||||||
spyOn(controller, 'applyVolumes');
|
jest.spyOn(controller, 'applyVolumes');
|
||||||
|
|
||||||
controller.sales = [{id: 1}];
|
controller.sales = [{id: 1}];
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ describe('ticket', () => {
|
||||||
|
|
||||||
describe('volumes() setter', () => {
|
describe('volumes() setter', () => {
|
||||||
it('should set volumes property on controller an then call applyVolumes() method', () => {
|
it('should set volumes property on controller an then call applyVolumes() method', () => {
|
||||||
spyOn(controller, 'applyVolumes');
|
jest.spyOn(controller, 'applyVolumes');
|
||||||
|
|
||||||
controller.volumes = [{id: 1}];
|
controller.volumes = [{id: 1}];
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ describe('Travel Component vnTravelBasicData', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should call the card reload method after the watcher submits', done => {
|
it('should call the card reload method after the watcher submits', done => {
|
||||||
spyOn(controller.card, 'reload');
|
jest.spyOn(controller.card, 'reload');
|
||||||
spyOn(controller.$.watcher, 'submit').and.returnValue(Promise.resolve());
|
jest.spyOn(controller.$.watcher, 'submit').mockReturnValue(Promise.resolve());
|
||||||
|
|
||||||
controller.onSubmit().then(() => {
|
controller.onSubmit().then(() => {
|
||||||
expect(controller.card.reload).toHaveBeenCalledWith();
|
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('Travel Component vnTravelCreate', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
|
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('travel Component vnTravelDescriptorPopover', () => {
|
||||||
it(`should not apply any changes if the received id is the same stored in _travelId`, () => {
|
it(`should not apply any changes if the received id is the same stored in _travelId`, () => {
|
||||||
controller.travel = 'I exist!';
|
controller.travel = 'I exist!';
|
||||||
controller._travelId = 1;
|
controller._travelId = 1;
|
||||||
spyOn(controller, 'loadData');
|
jest.spyOn(controller, 'loadData');
|
||||||
controller.travelId = 1;
|
controller.travelId = 1;
|
||||||
|
|
||||||
expect(controller.travel).toEqual('I exist!');
|
expect(controller.travel).toEqual('I exist!');
|
||||||
|
@ -33,7 +33,7 @@ describe('travel Component vnTravelDescriptorPopover', () => {
|
||||||
it(`should set the received id into _travelId, set the travel to null and then call loadData()`, () => {
|
it(`should set the received id into _travelId, set the travel to null and then call loadData()`, () => {
|
||||||
controller.travel = `Please don't`;
|
controller.travel = `Please don't`;
|
||||||
controller._travelId = 1;
|
controller._travelId = 1;
|
||||||
spyOn(controller, 'loadData');
|
jest.spyOn(controller, 'loadData');
|
||||||
controller.travelId = 999;
|
controller.travelId = 999;
|
||||||
|
|
||||||
expect(controller.travel).toBeNull();
|
expect(controller.travel).toBeNull();
|
||||||
|
@ -44,7 +44,7 @@ describe('travel Component vnTravelDescriptorPopover', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should call the show()`, () => {
|
it(`should call the show()`, () => {
|
||||||
spyOn(controller.$.popover, 'show');
|
jest.spyOn(controller.$.popover, 'show');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -21,9 +21,9 @@ describe('component vnTravelSummary', () => {
|
||||||
|
|
||||||
describe('travel setter/getter', () => {
|
describe('travel setter/getter', () => {
|
||||||
it('should return the travel and then call both getTravel() and getEntries()', () => {
|
it('should return the travel and then call both getTravel() and getEntries()', () => {
|
||||||
spyOn(controller, 'getTravel');
|
jest.spyOn(controller, 'getTravel');
|
||||||
spyOn(controller, 'getEntries');
|
jest.spyOn(controller, 'getEntries');
|
||||||
spyOn(controller, 'getThermographs');
|
jest.spyOn(controller, 'getThermographs');
|
||||||
controller.travel = {id: 99};
|
controller.travel = {id: 99};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
describe('travel() setter', () => {
|
describe('travel() setter', () => {
|
||||||
it('should set the travel data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the travel data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
jest.spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller.travel = {
|
controller.travel = {
|
||||||
id: travelId
|
id: travelId
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('worker Component vnWorkerDescriptorPopover', () => {
|
||||||
it(`should not apply any changes if the received id is the same stored in _workerFk`, () => {
|
it(`should not apply any changes if the received id is the same stored in _workerFk`, () => {
|
||||||
controller.worker = 'I exist!';
|
controller.worker = 'I exist!';
|
||||||
controller._workerFk = 1;
|
controller._workerFk = 1;
|
||||||
spyOn(controller, 'loadData');
|
jest.spyOn(controller, 'loadData');
|
||||||
controller.workerFk = 1;
|
controller.workerFk = 1;
|
||||||
|
|
||||||
expect(controller.worker).toEqual('I exist!');
|
expect(controller.worker).toEqual('I exist!');
|
||||||
|
@ -33,7 +33,7 @@ describe('worker Component vnWorkerDescriptorPopover', () => {
|
||||||
it(`should set the received id into _workerFk, set the worker to null and then call loadData()`, () => {
|
it(`should set the received id into _workerFk, set the worker to null and then call loadData()`, () => {
|
||||||
controller.worker = `Please don't`;
|
controller.worker = `Please don't`;
|
||||||
controller._workerFk = 1;
|
controller._workerFk = 1;
|
||||||
spyOn(controller, 'loadData');
|
jest.spyOn(controller, 'loadData');
|
||||||
controller.workerFk = 999;
|
controller.workerFk = 999;
|
||||||
|
|
||||||
expect(controller.worker).toBeNull();
|
expect(controller.worker).toBeNull();
|
||||||
|
@ -44,7 +44,7 @@ describe('worker Component vnWorkerDescriptorPopover', () => {
|
||||||
|
|
||||||
describe('show()', () => {
|
describe('show()', () => {
|
||||||
it(`should call the show()`, () => {
|
it(`should call the show()`, () => {
|
||||||
spyOn(controller.$.popover, 'show');
|
jest.spyOn(controller.$.popover, 'show');
|
||||||
controller.show();
|
controller.show();
|
||||||
|
|
||||||
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
expect(controller.$.popover.show).toHaveBeenCalledWith();
|
||||||
|
|
|
@ -21,8 +21,8 @@ describe('Client', () => {
|
||||||
|
|
||||||
describe('worker() setter', () => {
|
describe('worker() setter', () => {
|
||||||
it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
jest.spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller.worker = {
|
controller.worker = {
|
||||||
id: 15,
|
id: 15,
|
||||||
name: 'Bruce wayne'
|
name: 'Bruce wayne'
|
||||||
|
|
|
@ -20,8 +20,8 @@ describe('Worker', () => {
|
||||||
|
|
||||||
describe('worker() setter', () => {
|
describe('worker() setter', () => {
|
||||||
it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => {
|
||||||
spyOn(controller, 'setDefaultParams');
|
jest.spyOn(controller, 'setDefaultParams');
|
||||||
spyOn(controller, 'getAllowedContentTypes');
|
jest.spyOn(controller, 'getAllowedContentTypes');
|
||||||
controller._worker = undefined;
|
controller._worker = undefined;
|
||||||
controller.worker = {
|
controller.worker = {
|
||||||
id: 106
|
id: 106
|
||||||
|
|
|
@ -24,8 +24,8 @@ describe('Worker', () => {
|
||||||
it('should make an HTTP Post query', () => {
|
it('should make an HTTP Post query', () => {
|
||||||
const dmsId = 4;
|
const dmsId = 4;
|
||||||
const dmsIndex = 0;
|
const dmsIndex = 0;
|
||||||
spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
controller.workerDms = [{dmsFk: 4}];
|
controller.workerDms = [{dmsFk: 4}];
|
||||||
controller.dmsIndex = dmsIndex;
|
controller.dmsIndex = dmsIndex;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Component vnWorkerTimeControl', () => {
|
||||||
describe('date() setter', () => {
|
describe('date() setter', () => {
|
||||||
it(`should set the weekDays, the date in the controller and call fetchHours`, () => {
|
it(`should set the weekDays, the date in the controller and call fetchHours`, () => {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
spyOn(controller, 'fetchHours');
|
jest.spyOn(controller, 'fetchHours').mockReturnThis();
|
||||||
|
|
||||||
controller.date = today;
|
controller.date = today;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ describe('Component vnWorkerTimeControl', () => {
|
||||||
describe('hours() setter', () => {
|
describe('hours() setter', () => {
|
||||||
it(`should set hours data at it's corresponding week day`, () => {
|
it(`should set hours data at it's corresponding week day`, () => {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
spyOn(controller, 'fetchHours');
|
jest.spyOn(controller, 'fetchHours').mockReturnThis();
|
||||||
|
|
||||||
controller.date = today;
|
controller.date = today;
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ describe('Component vnWorkerTimeControl', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getWorkedHours() ', () => {
|
describe('getWorkedHours() ', () => {
|
||||||
it(`should `, () => {
|
it('should set the weekdays expected and worked hours plus the total worked hours', () => {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
spyOn(controller, 'fetchHours');
|
jest.spyOn(controller, 'fetchHours').mockReturnThis();
|
||||||
|
|
||||||
controller.date = today;
|
controller.date = today;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe('Zone Component vnZoneCreate', () => {
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
spyOn($state, 'go');
|
jest.spyOn($state, 'go');
|
||||||
|
|
||||||
controller.zone = {
|
controller.zone = {
|
||||||
name: 'Zone One'
|
name: 'Zone One'
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe('component vnZoneSummary', () => {
|
||||||
|
|
||||||
describe('zone setter', () => {
|
describe('zone setter', () => {
|
||||||
it('should set the zone and then call both getSummary() and getWarehouses()', () => {
|
it('should set the zone and then call both getSummary() and getWarehouses()', () => {
|
||||||
spyOn(controller, 'getSummary');
|
jest.spyOn(controller, 'getSummary');
|
||||||
spyOn(controller, 'getWarehouses');
|
jest.spyOn(controller, 'getWarehouses');
|
||||||
|
|
||||||
controller.zone = {id: 1};
|
controller.zone = {id: 1};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue