salix/modules/ticket/front/weekly/create/index.spec.js

61 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-07-29 11:12:36 +00:00
import './index';
2019-07-30 06:51:38 +00:00
describe('Ticket', () => {
2019-07-29 11:12:36 +00:00
describe('Component vnTicketWeeklyCreate', () => {
let $componentController;
let $scope;
let $state;
let controller;
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('ticket', $translateProvider => {
$translateProvider.translations('en', {});
}));
2019-07-29 11:12:36 +00:00
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_) => {
$componentController = _$componentController_;
$scope = $rootScope.$new();
$state = _$state_;
$scope.watcher = {
submit: () => {
return {
then: callback => {
callback({data: {id: '1234'}});
}
};
}
};
controller = $componentController('vnTicketWeeklyCreate', {$scope, $state});
}));
describe('onChangeTicket() setter', () => {
it(`should define clientFk and warehouseFk properties on ticketWeekly object`, () => {
controller.onChangeTicket({clientFk: 101, warehouseFk: 1});
expect(controller.ticketWeekly.clientFk).toEqual(101);
expect(controller.ticketWeekly.warehouseFk).toEqual(1);
});
});
describe('clientSelection() setter', () => {
it(`should define salesPersonFk property on ticketWeekly object`, () => {
controller.clientSelection = {clientFk: 101, salesPersonFk: 106};
expect(controller.ticketWeekly.salesPersonFk).toEqual(106);
});
});
describe('onSubmit()', () => {
it(`should call submit() on the watcher then expect a callback`, () => {
spyOn(controller.$state, 'go');
controller.ticketWeekly = {
ticketFk: 11,
weekDay: 0
};
controller.onSubmit();
expect(controller.$state.go).toHaveBeenCalledWith('ticket.weekly.index');
});
});
});
});