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

38 lines
1.4 KiB
JavaScript

import './index';
describe('Client', () => {
describe('Component vnClientLog', () => {
let $componentController;
let $scope;
let controller;
beforeEach(ngModule('client'));
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
$componentController = _$componentController_;
$scope = $rootScope.$new();
controller = $componentController('vnClientLog', {$scope: $scope});
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]};
}));
describe('logs setter', () => {
it('should call the function getInstance() twice', () => {
spyOn(controller, 'getInstance');
controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}];
expect(controller.getInstance.calls.count()).toBe(2);
expect(controller.getInstance).toHaveBeenCalledWith({id: 1});
expect(controller.getInstance).toHaveBeenCalledWith({id: 2});
});
});
describe('getInstance(instance)', () => {
it('should transform the object given in to an array', () => {
let newInstance = controller.getInstance(controller.$scope.model.data[0].newInstance);
expect(newInstance).toEqual([{key: 'id', value: 1}]);
});
});
});
});