63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
|
import './step-one.js';
|
||
|
|
||
|
describe('ticket', () => {
|
||
|
describe('Component vnTicketDataStepOne', () => {
|
||
|
let $componentController;
|
||
|
let $state;
|
||
|
let controller;
|
||
|
let $httpBackend;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
angular.mock.module('ticket');
|
||
|
});
|
||
|
|
||
|
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
|
||
|
$componentController = _$componentController_;
|
||
|
$state = _$state_;
|
||
|
$httpBackend = _$httpBackend_;
|
||
|
controller = $componentController('vnTicketDataStepOne', {$state: $state});
|
||
|
}));
|
||
|
|
||
|
describe('isFormInvalid()', () => {
|
||
|
it('should check if all form fields are valid', () => {
|
||
|
controller.ticket = {
|
||
|
clientFk: 1,
|
||
|
addressFk: 121,
|
||
|
agencyModeFk: 1,
|
||
|
companyFk: 442,
|
||
|
shipped: Date.now(),
|
||
|
landed: Date.now()
|
||
|
};
|
||
|
|
||
|
let result = controller.isFormInvalid();
|
||
|
expect(result).toBeFalsy();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
describe('onStepChange()', () => {
|
||
|
it('should call onStepChange method and return a NO_AGENCY_AVAILABLE signal error', async () => {
|
||
|
controller.ticket = {
|
||
|
id: 1,
|
||
|
clientFk: 1,
|
||
|
addressFk: 121,
|
||
|
agencyModeFk: 1,
|
||
|
companyFk: 442,
|
||
|
shipped: Date.now(),
|
||
|
landed: Date.now()
|
||
|
};
|
||
|
|
||
|
let data = {
|
||
|
addressFk: 121,
|
||
|
agencyModeFk: 1,
|
||
|
landed: Date.now()
|
||
|
};
|
||
|
let response = {error: {message: 'NO_AGENCY_AVAILABLE'}};
|
||
|
|
||
|
$httpBackend.whenPOST(`/ticket/api/sales/1/priceDifference`, data).respond(400, response);
|
||
|
$httpBackend.expectPOST(`/ticket/api/sales/1/priceDifference`, data);
|
||
|
controller.onStepChange();
|
||
|
$httpBackend.flush();
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|