#474 descriptor-popover Front unit test and refactor of other test
This commit is contained in:
parent
3916c2bf09
commit
c14fe295d7
|
@ -0,0 +1,49 @@
|
|||
import './index';
|
||||
|
||||
describe('Client', () => {
|
||||
describe('Component vnClientDescriptorPopover', () => {
|
||||
let $componentController;
|
||||
let $httpBackend;
|
||||
let $scope;
|
||||
let controller;
|
||||
let $element;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('client');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
||||
$componentController = _$componentController_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||||
$element = angular.element(`<div></div>`);
|
||||
$scope = $rootScope.$new();
|
||||
controller = $componentController('vnClientDescriptorPopover', {$scope: $scope, $element: $element});
|
||||
}));
|
||||
|
||||
describe('_getClientDebt()', () => {
|
||||
it(`should perform a get query to store the client debt into the controller`, () => {
|
||||
let clientFk = 1;
|
||||
$httpBackend.when('GET', `/client/api/Clients/${clientFk}/getDebt`).respond({debt: 100});
|
||||
$httpBackend.expect('GET', `/client/api/Clients/${clientFk}/getDebt`);
|
||||
controller._getClientDebt(clientFk);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.clientDebt).toEqual(100);
|
||||
});
|
||||
});
|
||||
|
||||
describe('_getClient()', () => {
|
||||
it(`should perform a get query to store the client data into the controller`, () => {
|
||||
let clientFk = 1;
|
||||
let response = {id: 1, name: 'name'};
|
||||
$httpBackend.when('GET', `/client/api/Clients/${clientFk}/card`).respond(response);
|
||||
$httpBackend.expect('GET', `/client/api/Clients/${clientFk}/card`);
|
||||
controller._getClient(clientFk);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.client).toEqual(response);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
const app = require(`../../../../server/server`);
|
||||
|
||||
describe('order getTotal()', () => {
|
||||
it('should call the getTaxes method and return undefined if its called with a string', async() => {
|
||||
it('should return the total', async() => {
|
||||
let result = await app.models.Order.getTotal(1);
|
||||
|
||||
expect(result.total).toEqual(14.45);
|
||||
|
|
Loading…
Reference in New Issue