fixed bug module importation + rewritten tests
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-06-07 11:12:56 +02:00
parent 2604c81533
commit 8fd7faa47b
2 changed files with 26 additions and 23 deletions

View File

@ -1,4 +1,4 @@
import ngModule from '../../../supplier/front/module';
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {

View File

@ -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(`<vn-invoice-in-create></vn-invoice-in-create>`);
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('<vn-invoice-in-create></vn-invoice-in-create>');
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});
});
});
});