87 lines
2.5 KiB
JavaScript
87 lines
2.5 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Component vnTicketIndex', () => {
|
|
let $element;
|
|
let controller;
|
|
let $window;
|
|
let tickets = [{
|
|
id: 1,
|
|
clientFk: 1,
|
|
salesPersonFk: 9,
|
|
shipped: new Date(),
|
|
nickname: 'Test',
|
|
total: 10.5
|
|
}];
|
|
|
|
beforeEach(() => {
|
|
ngModule('client');
|
|
ngModule('item');
|
|
ngModule('ticket');
|
|
});
|
|
|
|
beforeEach(inject(($compile, $rootScope, $httpBackend, _$window_) => {
|
|
$window = _$window_;
|
|
$element = $compile('<vn-ticket-index></vn-ticket-index>')($rootScope);
|
|
controller = $element.controller('vnTicketIndex');
|
|
}));
|
|
|
|
afterEach(() => {
|
|
$element.remove();
|
|
});
|
|
|
|
describe('compareDate()', () => {
|
|
it('should return warning when the date is the present', () => {
|
|
let curDate = new Date();
|
|
let result = controller.compareDate(curDate);
|
|
|
|
expect(result).toEqual('warning');
|
|
});
|
|
|
|
it('should return sucess when the date is in the future', () => {
|
|
let futureDate = new Date();
|
|
futureDate = futureDate.setDate(futureDate.getDate() + 10);
|
|
let result = controller.compareDate(futureDate);
|
|
|
|
expect(result).toEqual('success');
|
|
});
|
|
|
|
it('should return undefined when the date is in the past', () => {
|
|
let pastDate = new Date();
|
|
pastDate = pastDate.setDate(pastDate.getDate() - 10);
|
|
let result = controller.compareDate(pastDate);
|
|
|
|
expect(result).toEqual(undefined);
|
|
});
|
|
});
|
|
|
|
describe('showDescriptor()', () => {
|
|
it('should show the descriptor popover', () => {
|
|
spyOn(controller.$.descriptor, 'show');
|
|
|
|
let event = new MouseEvent('click', {
|
|
view: $window,
|
|
bubbles: true,
|
|
cancelable: true
|
|
});
|
|
controller.showDescriptor(event, tickets[0].clientFk);
|
|
|
|
expect(controller.$.descriptor.show).toHaveBeenCalledWith();
|
|
});
|
|
});
|
|
|
|
describe('preview()', () => {
|
|
it('should show the dialog summary', () => {
|
|
spyOn(controller.$.summary, 'show');
|
|
|
|
let event = new MouseEvent('click', {
|
|
view: $window,
|
|
bubbles: true,
|
|
cancelable: true
|
|
});
|
|
controller.preview(event, tickets[0]);
|
|
|
|
expect(controller.$.summary.show).toHaveBeenCalledWith();
|
|
});
|
|
});
|
|
});
|