2018-10-03 09:27:05 +00:00
|
|
|
import './index';
|
|
|
|
|
2018-10-03 09:28:50 +00:00
|
|
|
describe('Client', () => {
|
2018-10-30 07:03:26 +00:00
|
|
|
describe('Component vnClientLog', () => {
|
2018-10-03 09:27:05 +00:00
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
|
|
|
let controller;
|
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2018-10-03 09:27:05 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$scope = $rootScope.$new();
|
2018-10-30 07:03:26 +00:00
|
|
|
controller = $componentController('vnClientLog', {$scope: $scope});
|
2018-10-23 09:34:07 +00:00
|
|
|
controller.$scope.model = {data: [{newInstance: {id: 1}, oldInstance: {id: 2}}]};
|
2018-10-03 09:27:05 +00:00
|
|
|
}));
|
|
|
|
|
2018-10-23 09:34:07 +00:00
|
|
|
describe('logs setter', () => {
|
2018-10-03 09:27:05 +00:00
|
|
|
it('should call the function getInstance() twice', () => {
|
2018-10-23 09:34:07 +00:00
|
|
|
spyOn(controller, 'getInstance');
|
|
|
|
controller.logs = [{newInstance: {id: 1}, oldInstance: {id: 2}}];
|
2018-10-03 09:27:05 +00:00
|
|
|
|
|
|
|
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}]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|