salix/client/ticket/src/list/ticket-list.spec.js

49 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-04-19 12:56:05 +00:00
import './ticket-list.js';
describe('ticket', () => {
describe('Component vnTicketList', () => {
let $componentController;
let controller;
beforeEach(() => {
angular.mock.module('ticket');
});
beforeEach(angular.mock.inject(_$componentController_ => {
$componentController = _$componentController_;
controller = $componentController('vnTicketList');
}));
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');
});
it('should return warning when the date is in the future', () => {
let date = '2518-05-19T00:00:00.000Z';
let result = controller.compareDate(date);
expect(result).toEqual('success');
});
});
describe('preview()', () => {
it('should call preventDefault and stopImmediatePropagation from event and show', () => {
let event = jasmine.createSpyObj('event', ['preventDefault', 'stopImmediatePropagation']);
controller.$scope = {dialogSummaryTicket: {show: () => {}}};
spyOn(controller.$scope.dialogSummaryTicket, 'show');
let ticket = {};
controller.preview(event, ticket);
expect(event.preventDefault).toHaveBeenCalledWith();
expect(event.stopImmediatePropagation).toHaveBeenCalledWith();
expect(controller.$scope.dialogSummaryTicket.show).toHaveBeenCalledWith();
});
});
});
});