#1258 ticket.index sumatorio unit test fixed

This commit is contained in:
Carlos Jimenez Ruiz 2019-04-29 10:21:36 +02:00
parent 2ca85394f3
commit 10669f01f3
2 changed files with 17 additions and 32 deletions

View File

@ -1,7 +1,5 @@
import './index.js';
// #1258 ticket.index sumatorio
xdescribe('Component vnTicketIndex', () => {
let $element;
describe('Component vnTicketIndex', () => {
let controller;
let $window;
let tickets = [{
@ -11,7 +9,7 @@ xdescribe('Component vnTicketIndex', () => {
shipped: new Date(),
nickname: 'Test',
total: 10.5,
isChecked: false
checked: false
}, {
id: 2,
clientFk: 1,
@ -19,7 +17,7 @@ xdescribe('Component vnTicketIndex', () => {
shipped: new Date(),
nickname: 'Test',
total: 20.5,
isChecked: true
checked: true
}, {
id: 3,
clientFk: 1,
@ -27,27 +25,18 @@ xdescribe('Component vnTicketIndex', () => {
shipped: new Date(),
nickname: 'Test',
total: 30,
isChecked: true
checked: true
}];
beforeEach(() => {
ngModule('client');
ngModule('worker');
ngModule('item');
ngModule('ticket');
});
beforeEach(inject(($compile, $rootScope, _$window_) => {
beforeEach(inject(($componentController, _$window_) => {
$window = _$window_;
let $scope = $rootScope.$new();
$element = $compile('<vn-ticket-index></vn-ticket-index>')($scope);
controller = $element.controller('vnTicketIndex');
controller = $componentController('vnTicketIndex');
}));
afterEach(() => {
$element.remove();
});
describe('compareDate()', () => {
it('should return warning when the date is the present', () => {
let curDate = new Date();
@ -75,8 +64,8 @@ xdescribe('Component vnTicketIndex', () => {
describe('showClientDescriptor()', () => {
it('should show the client descriptor popover', () => {
spyOn(controller.$.clientDescriptor, 'show');
controller.$.clientDescriptor = {show: () => {}};
controller.$.clientDescriptor.show = jasmine.createSpy('show');
let event = new MouseEvent('click', {
view: $window,
bubbles: true,
@ -90,6 +79,7 @@ xdescribe('Component vnTicketIndex', () => {
describe('preview()', () => {
it('should show the dialog summary', () => {
controller.$.summary = {show: () => {}};
spyOn(controller.$.summary, 'show');
let event = new MouseEvent('click', {
@ -105,21 +95,16 @@ xdescribe('Component vnTicketIndex', () => {
describe('setBalanceCreateDialog()', () => {
it('should fill the object for the component balanceCreateDialog', () => {
console.log('2');
console.log(controller);
controller.$.tickets = tickets;
controller.$.balanceCreateDialog = {};
let result = controller.setBalanceCreateDialog();
controller.$.balanceCreateDialog.amountPaid = 0;
controller.setBalanceCreateDialog();
expect(result).toEqual(50.5);
});
let description = controller.$.balanceCreateDialog.description;
let amountPaid = controller.$.balanceCreateDialog.amountPaid;
it('should', () => {
// spyOn(controller.$.balanceCreateDialog, 'show');
// spyOn(controller.$, 'balanceCreateDialog');
// controller.setBalanceCreateDialog();
// expect(controller.$.balanceCreateDialog.description).toEqual('');
expect(true).toBeTruthy();
expect(description).toEqual('Albaran: 2, 3');
expect(amountPaid).toEqual(50.5);
});
});
});