import './index'; describe('Route', () => { describe('Component vnRouteLog', () => { let $componentController; let $scope; let controller; beforeEach(ngModule('route')); beforeEach(angular.mock.inject((_$componentController_, $rootScope) => { $componentController = _$componentController_; $scope = $rootScope.$new(); controller = $componentController('vnRouteLog', {$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}]); }); }); }); });