Loading public/js/app.js +8 −3 Original line number Diff line number Diff line Loading @@ -306,9 +306,14 @@ angular.module('cerebro').controller('CatController', ['$scope', CatDataService.get( api.replace(/ /g, '_'), // transforms thread pool into thread_pool, for example function(data) { if (data.length) { $scope.headers = Object.keys(data[0]); $scope.sort($scope.headers[0]); $scope.data = data; } else { $scope.headers = []; $scope.data = []; } }, function(error) { AlertService.error('Error executing request', error); Loading src/app/components/cat/controller.js +8 −3 Original line number Diff line number Diff line Loading @@ -32,9 +32,14 @@ angular.module('cerebro').controller('CatController', ['$scope', CatDataService.get( api.replace(/ /g, '_'), // transforms thread pool into thread_pool, for example function(data) { if (data.length) { $scope.headers = Object.keys(data[0]); $scope.sort($scope.headers[0]); $scope.data = data; } else { $scope.headers = []; $scope.data = []; } }, function(error) { AlertService.error('Error executing request', error); Loading tests/components/cat/controller.tests.js +11 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,17 @@ describe('CatController', function() { jasmine.any(Function) ); }); it('cleans up in case of empty response', function() { this.scope.headers = [1, 2, 3]; this.scope.data = [1, 2, 3]; this.CatDataService.get = function(api, success, error) { success([]); }; spyOn(this.CatDataService, 'get').andCallThrough(); this.scope.get('foo'); expect(this.scope.headers).toEqual([]); expect(this.scope.data).toEqual([]); }); it('alerts in case of failure', function() { this.CatDataService.get = function(api, success, error) { error('failed!'); Loading Loading
public/js/app.js +8 −3 Original line number Diff line number Diff line Loading @@ -306,9 +306,14 @@ angular.module('cerebro').controller('CatController', ['$scope', CatDataService.get( api.replace(/ /g, '_'), // transforms thread pool into thread_pool, for example function(data) { if (data.length) { $scope.headers = Object.keys(data[0]); $scope.sort($scope.headers[0]); $scope.data = data; } else { $scope.headers = []; $scope.data = []; } }, function(error) { AlertService.error('Error executing request', error); Loading
src/app/components/cat/controller.js +8 −3 Original line number Diff line number Diff line Loading @@ -32,9 +32,14 @@ angular.module('cerebro').controller('CatController', ['$scope', CatDataService.get( api.replace(/ /g, '_'), // transforms thread pool into thread_pool, for example function(data) { if (data.length) { $scope.headers = Object.keys(data[0]); $scope.sort($scope.headers[0]); $scope.data = data; } else { $scope.headers = []; $scope.data = []; } }, function(error) { AlertService.error('Error executing request', error); Loading
tests/components/cat/controller.tests.js +11 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,17 @@ describe('CatController', function() { jasmine.any(Function) ); }); it('cleans up in case of empty response', function() { this.scope.headers = [1, 2, 3]; this.scope.data = [1, 2, 3]; this.CatDataService.get = function(api, success, error) { success([]); }; spyOn(this.CatDataService, 'get').andCallThrough(); this.scope.get('foo'); expect(this.scope.headers).toEqual([]); expect(this.scope.data).toEqual([]); }); it('alerts in case of failure', function() { this.CatDataService.get = function(api, success, error) { error('failed!'); Loading