falta solucionar test
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
70fc260eae
commit
2604c81533
|
@ -1,104 +0,0 @@
|
||||||
import './card.js';
|
|
||||||
|
|
||||||
xdescribe('Order', () => {
|
|
||||||
describe('Component vnOrderCreateCard', () => {
|
|
||||||
let controller;
|
|
||||||
let $httpBackend;
|
|
||||||
let $scope;
|
|
||||||
|
|
||||||
beforeEach(ngModule('order'));
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, _$httpBackend_, _vnApp_, $rootScope) => {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
const $element = angular.element('<vn-order-create-card></vn-order-create-card>');
|
|
||||||
controller = $componentController('vnOrderCreateCard', {$element, $scope});
|
|
||||||
controller.item = {id: 3};
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('set order', () => {
|
|
||||||
it(`should set order if the value given is not null`, () => {
|
|
||||||
controller.order = 1;
|
|
||||||
|
|
||||||
expect(controller.order).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('set clientFk', () => {
|
|
||||||
it(`should set addressFk to null and clientFk to a value and set addressFk to a value given`, () => {
|
|
||||||
let filter = {
|
|
||||||
include: {
|
|
||||||
relation: 'defaultAddress',
|
|
||||||
scope: {
|
|
||||||
fields: 'id'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
where: {id: 2}
|
|
||||||
};
|
|
||||||
filter = encodeURIComponent(JSON.stringify(filter));
|
|
||||||
let response = [
|
|
||||||
{
|
|
||||||
defaultAddress: {id: 1}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
$httpBackend.whenGET(`Clients?filter=${filter}`).respond(response);
|
|
||||||
$httpBackend.expectGET(`Clients?filter=${filter}`);
|
|
||||||
|
|
||||||
controller.clientFk = 2;
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.clientFk).toEqual(2);
|
|
||||||
expect(controller.order.addressFk).toBe(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('set addressFk', () => {
|
|
||||||
it(`should set agencyModeFk property to null and addressFk to a value`, () => {
|
|
||||||
controller.addressFk = 101;
|
|
||||||
|
|
||||||
expect(controller.addressFk).toEqual(101);
|
|
||||||
expect(controller.order.agencyModeFk).toBe(null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getAvailableAgencies()', () => {
|
|
||||||
it(`should make a query if landed and addressFk exists`, () => {
|
|
||||||
controller.order.addressFk = 101;
|
|
||||||
controller.order.landed = 101;
|
|
||||||
|
|
||||||
$httpBackend.whenRoute('GET', 'Agencies/landsThatDay')
|
|
||||||
.respond({data: 1});
|
|
||||||
|
|
||||||
controller.getAvailableAgencies();
|
|
||||||
$httpBackend.flush();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
|
||||||
it(`should call createOrder()`, () => {
|
|
||||||
jest.spyOn(controller, 'createOrder');
|
|
||||||
controller.onSubmit();
|
|
||||||
|
|
||||||
expect(controller.createOrder).toHaveBeenCalledWith();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('createOrder()', () => {
|
|
||||||
it(`should make a query, call vnApp.showSuccess and $state.go if the response is defined`, () => {
|
|
||||||
controller.order.landed = 101;
|
|
||||||
controller.order.addressFk = 101;
|
|
||||||
controller.order.agencyModeFk = 101;
|
|
||||||
|
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
||||||
jest.spyOn(controller.$state, 'go');
|
|
||||||
$httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1);
|
|
||||||
controller.createOrder();
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('order.card.catalog', {id: 1});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,39 +1,44 @@
|
||||||
import './index.js';
|
import './index.js';
|
||||||
|
|
||||||
describe('InvoiceIn', () => {
|
fdescribe('InvoiceIn', () => {
|
||||||
describe('Component vnInvoiceInCreate', () => {
|
describe('Component vnInvoiceInCreate', () => {
|
||||||
let $scope;
|
|
||||||
let controller;
|
let controller;
|
||||||
|
let $element;
|
||||||
|
|
||||||
beforeEach(ngModule('invoiceIn'));
|
beforeEach(ngModule('invoiceIn'));
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope) => {
|
beforeEach(inject(($componentController, $compile, $rootScope) => {
|
||||||
$scope = $rootScope.$new();
|
$element = angular.element(`<vn-invoice-in-create></vn-invoice-in-create>`);
|
||||||
$scope.card = {createInvoiceIn: () => {}};
|
|
||||||
const $element = angular.element('<vn-invoice-in-create></vn-invoice-in-create>');
|
|
||||||
console.log($element);
|
console.log($element);
|
||||||
console.log($scope);
|
controller = $componentController('vnInvoiceInCreate', {$element});
|
||||||
controller = $componentController('vnInvoiceIn', {$element, $scope});
|
// controller = $element.controller('Controller');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
$element.remove();
|
||||||
|
});
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call createInvoiceIn()`, () => {
|
it(`should call createInvoiceIn()`, () => {
|
||||||
jest.spyOn(controller, 'createOrder');
|
jest.spyOn(controller, 'createInvoiceIn');
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
|
|
||||||
expect(controller.createOrder).toHaveBeenCalledWith();
|
expect(controller.createInvoiceIn).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should call go()`, async() => {
|
describe('onInit()', () => {
|
||||||
jest.spyOn(controller.$state, 'go');
|
it(`should define invoiceIn supplierFk with params values()`, () => {
|
||||||
await controller.onSubmit();
|
controller.params = 'supplierId';
|
||||||
|
controller.$onInit();
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('order.invoiceIn.summary', {id: undefined});
|
expect(controller.invoiceIn.supplierFk).toEqual('supplierId');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('set companyFk', () => {
|
describe('set companyFk', () => {
|
||||||
it(`should set companyFk to a value`, () => {
|
it(`should set companyFk to a value`, () => {
|
||||||
|
console.log(controller);
|
||||||
controller.companyFk = 442;
|
controller.companyFk = 442;
|
||||||
|
|
||||||
expect(controller.companyFk).toEqual(442);
|
expect(controller.companyFk).toEqual(442);
|
||||||
|
|
Loading…
Reference in New Issue