2018-05-25 08:03:45 +00:00
|
|
|
import './index.js';
|
2018-04-19 12:56:05 +00:00
|
|
|
|
|
|
|
describe('ticket', () => {
|
2018-05-25 08:03:45 +00:00
|
|
|
describe('Component vnTicketIndex', () => {
|
2018-04-19 12:56:05 +00:00
|
|
|
let $componentController;
|
|
|
|
let controller;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
angular.mock.module('ticket');
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(angular.mock.inject(_$componentController_ => {
|
|
|
|
$componentController = _$componentController_;
|
2018-05-25 08:03:45 +00:00
|
|
|
controller = $componentController('vnTicketIndex');
|
2018-04-19 12:56:05 +00:00
|
|
|
}));
|
|
|
|
|
2018-08-13 07:32:33 +00:00
|
|
|
describe('exprBuilder()', () => {
|
|
|
|
it('should return a formated object with the id in case of search', () => {
|
|
|
|
let param = 'search';
|
|
|
|
let value = 1;
|
|
|
|
let result = controller.exprBuilder(param, value);
|
|
|
|
|
|
|
|
expect(result).toEqual({id: 1});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return a formated object with the nickname in case of search', () => {
|
|
|
|
let param = 'search';
|
|
|
|
let value = 'Bruce';
|
|
|
|
let result = controller.exprBuilder(param, value);
|
|
|
|
|
|
|
|
expect(result).toEqual({nickname: {regexp: 'Bruce'}});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return a formated object with the date in case of from', () => {
|
|
|
|
let param = 'from';
|
|
|
|
let value = 'Fri Aug 10 2018 11:39:21 GMT+0200';
|
|
|
|
let result = controller.exprBuilder(param, value);
|
|
|
|
|
|
|
|
expect(result).toEqual({shipped: {gte: 'Fri Aug 10 2018 11:39:21 GMT+0200'}});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return a formated object with the date in case of to', () => {
|
|
|
|
let param = 'to';
|
|
|
|
let value = 'Fri Aug 10 2018 11:39:21 GMT+0200';
|
|
|
|
let result = controller.exprBuilder(param, value);
|
|
|
|
|
|
|
|
expect(result).toEqual({shipped: {lte: 'Fri Aug 10 2018 11:39:21 GMT+0200'}});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return a formated object with the nickname in case of nickname', () => {
|
|
|
|
let param = 'nickname';
|
|
|
|
let value = 'Bruce';
|
|
|
|
let result = controller.exprBuilder(param, value);
|
|
|
|
|
|
|
|
expect(result).toEqual({nickname: {regexp: 'Bruce'}});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return a formated object with the warehouseFk in case of warehouseFk', () => {
|
|
|
|
let param = 'warehouseFk';
|
|
|
|
let value = 'Silla';
|
|
|
|
let result = controller.exprBuilder(param, value);
|
|
|
|
|
|
|
|
expect(result).toEqual({warehouseFk: 'Silla'});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-04-19 12:56:05 +00:00
|
|
|
describe('compareDate()', () => {
|
|
|
|
it('should return warning when the date is the present', () => {
|
|
|
|
let date = new Date();
|
|
|
|
let result = controller.compareDate(date);
|
|
|
|
|
|
|
|
expect(result).toEqual('warning');
|
|
|
|
});
|
|
|
|
|
2018-08-13 07:32:33 +00:00
|
|
|
it('should return sucess when the date is in the future', () => {
|
|
|
|
let futureDate = '2518-05-19T00:00:00.000Z';
|
|
|
|
let result = controller.compareDate(futureDate);
|
2018-04-19 12:56:05 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('success');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('preview()', () => {
|
|
|
|
it('should call preventDefault and stopImmediatePropagation from event and show', () => {
|
|
|
|
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopImmediatePropagation']);
|
|
|
|
|
2018-06-07 21:47:19 +00:00
|
|
|
controller.$ = {dialogSummaryTicket: {show: () => {}}};
|
|
|
|
spyOn(controller.$.dialogSummaryTicket, 'show');
|
2018-04-19 12:56:05 +00:00
|
|
|
let ticket = {};
|
|
|
|
controller.preview(event, ticket);
|
|
|
|
|
|
|
|
expect(event.preventDefault).toHaveBeenCalledWith();
|
|
|
|
expect(event.stopImmediatePropagation).toHaveBeenCalledWith();
|
2018-06-07 21:47:19 +00:00
|
|
|
expect(controller.$.dialogSummaryTicket.show).toHaveBeenCalledWith();
|
2018-04-19 12:56:05 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|