salix/modules/client/front/balance/index/index.spec.js

35 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-11-14 09:55:15 +00:00
import './index';
describe('Client', () => {
describe('Component vnClientBalanceIndex', () => {
2018-11-14 09:55:15 +00:00
let $componentController;
let controller;
beforeEach(ngModule('client'));
2018-11-14 09:55:15 +00:00
2020-01-02 13:44:51 +00:00
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
2018-11-14 09:55:15 +00:00
$componentController = _$componentController_;
2020-01-02 13:44:51 +00:00
let $scope = $rootScope.$new();
controller = $componentController('vnClientBalanceIndex', {$scope});
2020-01-02 13:44:51 +00:00
controller._companyFk = 442;
controller.$stateParams.id = 101;
2018-11-14 09:55:15 +00:00
2020-01-02 13:44:51 +00:00
controller.$.model = {applyFilter: () => {}};
controller.$.riskModel = {applyFilter: () => {}};
}));
2018-11-14 09:55:15 +00:00
2020-01-02 13:44:51 +00:00
describe('getData()', () => {
it('should apply the filters on he models and get the client balance', () => {
spyOn(controller, 'getBalances');
spyOn(controller.$.model, 'applyFilter').and.returnValue(Promise.resolve());
spyOn(controller.$.riskModel, 'applyFilter').and.returnValue(Promise.resolve());
controller.getData().then(() => {
expect(controller.$.model.applyFilter).toHaveBeenCalledWith(null, {'clientFk': 101, 'companyFk': 442});
expect(controller.$.riskModel.applyFilter).toHaveBeenCalledWith({'where': {'clientFk': 101, 'companyFk': 442}});
expect(controller.getBalances).toHaveBeenCalledWith();
});
2018-11-14 09:55:15 +00:00
});
});
});
});