diff --git a/modules/invoiceIn/front/create/index.js b/modules/invoiceIn/front/create/index.js index 2eb76b931..186f5d478 100644 --- a/modules/invoiceIn/front/create/index.js +++ b/modules/invoiceIn/front/create/index.js @@ -1,4 +1,4 @@ -import ngModule from '../../../supplier/front/module'; +import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { diff --git a/modules/invoiceIn/front/create/index.spec.js b/modules/invoiceIn/front/create/index.spec.js index 2708b5860..93109346c 100644 --- a/modules/invoiceIn/front/create/index.spec.js +++ b/modules/invoiceIn/front/create/index.spec.js @@ -1,47 +1,50 @@ import './index.js'; +import watcher from 'core/mocks/watcher'; -fdescribe('InvoiceIn', () => { +describe('InvoiceIn', () => { describe('Component vnInvoiceInCreate', () => { let controller; let $element; beforeEach(ngModule('invoiceIn')); - beforeEach(inject(($componentController, $compile, $rootScope) => { - $element = angular.element(``); - console.log($element); - controller = $componentController('vnInvoiceInCreate', {$element}); - // controller = $element.controller('Controller'); + beforeEach(inject(($componentController, $rootScope) => { + const $scope = $rootScope.$new(); + $scope.watcher = watcher; + $element = angular.element(''); + controller = $componentController('vnInvoiceInCreate', {$element, $scope}); + controller.$params = {}; })); afterEach(() => { $element.remove(); }); - describe('onSubmit()', () => { - it(`should call createInvoiceIn()`, () => { - jest.spyOn(controller, 'createInvoiceIn'); - controller.onSubmit(); - - expect(controller.createInvoiceIn).toHaveBeenCalledWith(); - }); - }); - describe('onInit()', () => { - it(`should define invoiceIn supplierFk with params values()`, () => { - controller.params = 'supplierId'; + it(`should defined the controller's invoiceIn property`, () => { + expect(controller.invoiceIn).toBeUndefined(); + + controller.$onInit(); + + expect(controller.invoiceIn).toEqual({}); + }); + + it(`should define invoiceIn and it's supplierFk when received via params`, () => { + controller.$params.supplierFk = 'supplierId'; + controller.$onInit(); expect(controller.invoiceIn.supplierFk).toEqual('supplierId'); }); }); - describe('set companyFk', () => { - it(`should set companyFk to a value`, () => { - console.log(controller); - controller.companyFk = 442; + describe('onSubmit()', () => { + it(`should redirect to basic data by calling the $state.go function`, () => { + jest.spyOn(controller.$state, 'go'); - expect(controller.companyFk).toEqual(442); + controller.onSubmit(); + + expect(controller.$state.go).toHaveBeenCalledWith('invoiceIn.card.basicData', {id: 1234}); }); }); });