#514 ticket step 3 clientside unit tests
This commit is contained in:
parent
b43f8d2d58
commit
5b81308cd9
|
@ -1,4 +1,4 @@
|
||||||
/* import './index.js';
|
import './index.js';
|
||||||
|
|
||||||
describe('ticket', () => {
|
describe('ticket', () => {
|
||||||
describe('Component vnTicketDataStepThree', () => {
|
describe('Component vnTicketDataStepThree', () => {
|
||||||
|
@ -6,20 +6,36 @@ describe('ticket', () => {
|
||||||
let $state;
|
let $state;
|
||||||
let controller;
|
let controller;
|
||||||
let $httpBackend;
|
let $httpBackend;
|
||||||
|
let vnApp;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
angular.mock.module('ticket');
|
angular.mock.module('ticket');
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
|
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_, _vnApp_) => {
|
||||||
$componentController = _$componentController_;
|
$componentController = _$componentController_;
|
||||||
$state = _$state_;
|
$state = _$state_;
|
||||||
|
spyOn($state, 'go');
|
||||||
|
vnApp = _vnApp_;
|
||||||
|
spyOn(vnApp, 'showError');
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||||||
controller = $componentController('vnTicketDataStepThree', {$state: $state});
|
controller = $componentController('vnTicketDataStepThree', {$state: $state});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should call onSubmit()', () => {
|
it(`should return an error if the item doesn't have option property in the controller`, () => {
|
||||||
|
controller.ticket = {};
|
||||||
|
|
||||||
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(vnApp.showError).toHaveBeenCalledWith('Choose an option');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should perform a post query correctly then call two functions()', () => {
|
||||||
|
controller.card = {reload: () => {}};
|
||||||
|
spyOn(controller.card, 'reload');
|
||||||
|
|
||||||
controller.ticket = {
|
controller.ticket = {
|
||||||
id: 1,
|
id: 1,
|
||||||
agencyModeFk: 1,
|
agencyModeFk: 1,
|
||||||
|
@ -39,13 +55,14 @@ describe('ticket', () => {
|
||||||
option: 1
|
option: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = {data: {error: {message: 'NOTHING_HERE'}}};
|
$httpBackend.whenPOST(`/ticket/api/tickets/1/componentUpdate`, data).respond('ok');
|
||||||
|
$httpBackend.expectPOST(`/ticket/api/tickets/1/componentUpdate`, data);
|
||||||
|
controller.onSubmit();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
$httpBackend.whenPOST(`/ticket/api/tickets/1/componentUpdate`, data).respond(400, response);
|
expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', jasmine.any(Object));
|
||||||
$httpBackend.expectPOST(`/ticket/api/tickets/1/componentUpdate`, data);
|
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||||
controller.onSubmit();
|
|
||||||
$httpBackend.flush();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}); */
|
});
|
||||||
|
|
Loading…
Reference in New Issue