126 lines
3.6 KiB
JavaScript
126 lines
3.6 KiB
JavaScript
import './index.js';
|
|
|
|
xdescribe('Component vnTicketIndex', () => {
|
|
let $element;
|
|
let controller;
|
|
let $window;
|
|
let tickets = [{
|
|
id: 1,
|
|
clientFk: 1,
|
|
salesPersonFk: 9,
|
|
shipped: new Date(),
|
|
nickname: 'Test',
|
|
total: 10.5,
|
|
isChecked: false
|
|
}, {
|
|
id: 2,
|
|
clientFk: 1,
|
|
salesPersonFk: 9,
|
|
shipped: new Date(),
|
|
nickname: 'Test',
|
|
total: 20.5,
|
|
isChecked: true
|
|
}, {
|
|
id: 3,
|
|
clientFk: 1,
|
|
salesPersonFk: 9,
|
|
shipped: new Date(),
|
|
nickname: 'Test',
|
|
total: 30,
|
|
isChecked: true
|
|
}];
|
|
|
|
beforeEach(() => {
|
|
ngModule('client');
|
|
ngModule('worker');
|
|
ngModule('item');
|
|
ngModule('ticket');
|
|
});
|
|
|
|
beforeEach(inject(($compile, $rootScope, _$window_) => {
|
|
$window = _$window_;
|
|
let $scope = $rootScope.$new();
|
|
$element = $compile('<vn-ticket-index></vn-ticket-index>')($scope);
|
|
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('showClientDescriptor()', () => {
|
|
it('should show the client descriptor popover', () => {
|
|
spyOn(controller.$.clientDescriptor, 'show');
|
|
|
|
let event = new MouseEvent('click', {
|
|
view: $window,
|
|
bubbles: true,
|
|
cancelable: true
|
|
});
|
|
controller.showClientDescriptor(event, tickets[0].clientFk);
|
|
|
|
expect(controller.$.clientDescriptor.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();
|
|
});
|
|
});
|
|
|
|
describe('setBalanceCreateDialog()', () => {
|
|
it('should fill the object for the component balanceCreateDialog', () => {
|
|
console.log('2');
|
|
console.log(controller);
|
|
controller.$.balanceCreateDialog = {};
|
|
let result = controller.setBalanceCreateDialog();
|
|
|
|
expect(result).toEqual(50.5);
|
|
});
|
|
|
|
it('should', () => {
|
|
// spyOn(controller.$.balanceCreateDialog, 'show');
|
|
// spyOn(controller.$, 'balanceCreateDialog');
|
|
// controller.setBalanceCreateDialog();
|
|
|
|
// expect(controller.$.balanceCreateDialog.description).toEqual('');
|
|
expect(true).toBeTruthy();
|
|
});
|
|
});
|
|
});
|