salix/modules/invoiceIn/front/create/index.spec.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-05-31 06:21:16 +00:00
import './index.js';
2021-06-01 08:10:09 +00:00
describe('InvoiceIn', () => {
describe('Component vnInvoiceInCreate', () => {
2021-05-31 06:21:16 +00:00
let $scope;
let controller;
2021-06-01 08:10:09 +00:00
beforeEach(ngModule('invoiceIn'));
2021-05-31 06:21:16 +00:00
beforeEach(inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
2021-06-01 08:10:09 +00:00
$scope.card = {createInvoiceIn: () => {}};
const $element = angular.element('<vn-invoice-in-create></vn-invoice-in-create>');
console.log($element);
console.log($scope);
controller = $componentController('vnInvoiceIn', {$element, $scope});
2021-05-31 06:21:16 +00:00
}));
describe('onSubmit()', () => {
2021-06-01 08:10:09 +00:00
it(`should call createInvoiceIn()`, () => {
jest.spyOn(controller, 'createOrder');
2021-05-31 06:21:16 +00:00
controller.onSubmit();
2021-06-01 08:10:09 +00:00
expect(controller.createOrder).toHaveBeenCalledWith();
2021-05-31 06:21:16 +00:00
});
it(`should call go()`, async() => {
jest.spyOn(controller.$state, 'go');
await controller.onSubmit();
2021-06-01 08:10:09 +00:00
expect(controller.$state.go).toHaveBeenCalledWith('order.invoiceIn.summary', {id: undefined});
});
});
describe('set companyFk', () => {
it(`should set companyFk to a value`, () => {
controller.companyFk = 442;
expect(controller.companyFk).toEqual(442);
2021-05-31 06:21:16 +00:00
});
});
});
});