2021-05-31 06:21:16 +00:00
|
|
|
import './index.js';
|
2021-06-07 09:12:56 +00:00
|
|
|
import watcher from 'core/mocks/watcher';
|
2021-05-31 06:21:16 +00:00
|
|
|
|
2021-06-07 09:12:56 +00:00
|
|
|
describe('InvoiceIn', () => {
|
2021-06-01 08:10:09 +00:00
|
|
|
describe('Component vnInvoiceInCreate', () => {
|
2021-05-31 06:21:16 +00:00
|
|
|
let controller;
|
2021-06-04 06:24:33 +00:00
|
|
|
let $element;
|
2021-05-31 06:21:16 +00:00
|
|
|
|
2021-06-01 08:10:09 +00:00
|
|
|
beforeEach(ngModule('invoiceIn'));
|
2021-05-31 06:21:16 +00:00
|
|
|
|
2021-06-07 09:12:56 +00:00
|
|
|
beforeEach(inject(($componentController, $rootScope) => {
|
|
|
|
const $scope = $rootScope.$new();
|
|
|
|
$scope.watcher = watcher;
|
|
|
|
$element = angular.element('<vn-invoice-in-create></vn-invoice-in-create>');
|
|
|
|
controller = $componentController('vnInvoiceInCreate', {$element, $scope});
|
|
|
|
controller.$params = {};
|
2021-05-31 06:21:16 +00:00
|
|
|
}));
|
|
|
|
|
2021-06-04 06:24:33 +00:00
|
|
|
afterEach(() => {
|
|
|
|
$element.remove();
|
|
|
|
});
|
|
|
|
|
2021-06-07 09:12:56 +00:00
|
|
|
describe('onInit()', () => {
|
|
|
|
it(`should defined the controller's invoiceIn property`, () => {
|
|
|
|
expect(controller.invoiceIn).toBeUndefined();
|
2021-05-31 06:21:16 +00:00
|
|
|
|
2021-06-07 09:12:56 +00:00
|
|
|
controller.$onInit();
|
|
|
|
|
|
|
|
expect(controller.invoiceIn).toEqual({});
|
2021-05-31 06:21:16 +00:00
|
|
|
});
|
|
|
|
|
2021-06-07 09:12:56 +00:00
|
|
|
it(`should define invoiceIn and it's supplierFk when received via params`, () => {
|
|
|
|
controller.$params.supplierFk = 'supplierId';
|
|
|
|
|
2021-06-04 06:24:33 +00:00
|
|
|
controller.$onInit();
|
2021-05-31 06:21:16 +00:00
|
|
|
|
2021-06-04 06:24:33 +00:00
|
|
|
expect(controller.invoiceIn.supplierFk).toEqual('supplierId');
|
2021-06-01 08:10:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-06-07 09:12:56 +00:00
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it(`should redirect to basic data by calling the $state.go function`, () => {
|
|
|
|
jest.spyOn(controller.$state, 'go');
|
|
|
|
|
|
|
|
controller.onSubmit();
|
2021-06-01 08:10:09 +00:00
|
|
|
|
2021-06-07 09:12:56 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('invoiceIn.card.basicData', {id: 1234});
|
2021-05-31 06:21:16 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|