test front
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
02cd2283a7
commit
e217f02321
|
@ -5,24 +5,11 @@ class Controller extends Section {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
}
|
||||
/*
|
||||
get invoiceIn() {
|
||||
return this._invoiceIn;
|
||||
}
|
||||
|
||||
set invoiceIn(value) {
|
||||
this._invoiceIn = value;
|
||||
if (value) {
|
||||
const filter = {
|
||||
currency: this.invoiceIn.currency
|
||||
}
|
||||
this.$http.get(`ReferenceRates`, {filter})
|
||||
.then(res => this.referenceRate = res.data);
|
||||
}
|
||||
}*/
|
||||
get setTaxRate() {
|
||||
return this._setTaxRate;
|
||||
}
|
||||
|
||||
set setTaxRate(selection) {
|
||||
this._setTaxRate = selection;
|
||||
const taxTypeSage = this.$.taxTypeSage.selection;
|
||||
|
@ -32,13 +19,11 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
add() {
|
||||
const defaultExpenseFk = 6000000001;
|
||||
|
||||
this.$.model.insert({
|
||||
invoiceIn: this.$params.id,
|
||||
expenseFk: defaultExpenseFk
|
||||
invoiceIn: this.$params.id
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.$.watcher.check();
|
||||
this.$.model.save().then(() => {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
import './index.js';
|
||||
import watcher from 'core/mocks/watcher';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('InvoiceIn', () => {
|
||||
describe('Component tax', () => {
|
||||
let controller;
|
||||
let $scope;
|
||||
let vnApp;
|
||||
|
||||
beforeEach(ngModule('invoiceIn'));
|
||||
|
||||
beforeEach(inject(($componentController, _$httpBackend_, $rootScope, _vnApp_) => {
|
||||
vnApp = _vnApp_;
|
||||
jest.spyOn(vnApp, 'showError');
|
||||
$scope = $rootScope.$new();
|
||||
$scope.model = crudModel;
|
||||
|
||||
$scope.watcher = watcher;
|
||||
const $element = angular.element('<vn-invoice-in-tax></vn-invoice-in-tax>');
|
||||
controller = $componentController('vnInvoiceInTax', {$element, $scope});
|
||||
controller.invoiceIn = {id: 1};
|
||||
}));
|
||||
|
||||
describe('setTaxRate() setter', () => {
|
||||
it('should set tax rate with the Sage tax type value', () => {
|
||||
const taxTypeSage = {
|
||||
rate: 21
|
||||
};
|
||||
$scope.taxTypeSage = {};
|
||||
$scope.taxTypeSage.selection = taxTypeSage;
|
||||
|
||||
$scope.taxableBase = {};
|
||||
$scope.taxableBase.value = 100;
|
||||
|
||||
controller.setTaxRate = 0;
|
||||
|
||||
expect(controller.taxRate).toEqual(21);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should make HTTP POST request to save tax values', () => {
|
||||
controller.card = {reload: () => {}};
|
||||
jest.spyOn($scope.watcher, 'check');
|
||||
jest.spyOn($scope.watcher, 'notifySaved');
|
||||
jest.spyOn($scope.watcher, 'updateOriginalData');
|
||||
jest.spyOn(controller.card, 'reload');
|
||||
jest.spyOn($scope.model, 'save');
|
||||
|
||||
controller.onSubmit();
|
||||
|
||||
expect($scope.model.save).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.check).toHaveBeenCalledWith();
|
||||
expect($scope.watcher.notifySaved).toHaveBeenCalledWith();
|
||||
expect(controller.card.reload).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue