2742--invoiceIn-create #670
|
@ -1,4 +1,4 @@
|
||||||
import ngModule from '../../../supplier/front/module';
|
import ngModule from '../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
|
|
|
@ -1,47 +1,50 @@
|
||||||
import './index.js';
|
import './index.js';
|
||||||
|
import watcher from 'core/mocks/watcher';
|
||||||
|
|
||||||
fdescribe('InvoiceIn', () => {
|
describe('InvoiceIn', () => {
|
||||||
describe('Component vnInvoiceInCreate', () => {
|
describe('Component vnInvoiceInCreate', () => {
|
||||||
let controller;
|
let controller;
|
||||||
let $element;
|
let $element;
|
||||||
|
|
||||||
beforeEach(ngModule('invoiceIn'));
|
beforeEach(ngModule('invoiceIn'));
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $compile, $rootScope) => {
|
beforeEach(inject(($componentController, $rootScope) => {
|
||||||
$element = angular.element(`<vn-invoice-in-create></vn-invoice-in-create>`);
|
const $scope = $rootScope.$new();
|
||||||
console.log($element);
|
$scope.watcher = watcher;
|
||||||
controller = $componentController('vnInvoiceInCreate', {$element});
|
$element = angular.element('<vn-invoice-in-create></vn-invoice-in-create>');
|
||||||
// controller = $element.controller('Controller');
|
controller = $componentController('vnInvoiceInCreate', {$element, $scope});
|
||||||
|
controller.$params = {};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
$element.remove();
|
$element.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
|
||||||
it(`should call createInvoiceIn()`, () => {
|
|
||||||
jest.spyOn(controller, 'createInvoiceIn');
|
|
||||||
controller.onSubmit();
|
|
||||||
|
|
||||||
expect(controller.createInvoiceIn).toHaveBeenCalledWith();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onInit()', () => {
|
describe('onInit()', () => {
|
||||||
it(`should define invoiceIn supplierFk with params values()`, () => {
|
it(`should defined the controller's invoiceIn property`, () => {
|
||||||
controller.params = 'supplierId';
|
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();
|
controller.$onInit();
|
||||||
|
|
||||||
expect(controller.invoiceIn.supplierFk).toEqual('supplierId');
|
expect(controller.invoiceIn.supplierFk).toEqual('supplierId');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('set companyFk', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should set companyFk to a value`, () => {
|
it(`should redirect to basic data by calling the $state.go function`, () => {
|
||||||
console.log(controller);
|
jest.spyOn(controller.$state, 'go');
|
||||||
controller.companyFk = 442;
|
|
||||||
|
|
||||||
expect(controller.companyFk).toEqual(442);
|
controller.onSubmit();
|
||||||
|
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith('invoiceIn.card.basicData', {id: 1234});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue