diff --git a/app/js/main.js b/app/js/main.js index 6b6e229..0cbc6fa 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -35,8 +35,8 @@ var bootstrap = function() { angular.bootstrap(document, ['app']); window.bootstrap = null; - }; + // create and bootstrap application angular.element(document).ready(bootstrap); window.bootstrap = bootstrap; diff --git a/test/unit/controllers/example_spec.js b/test/unit/controllers/example_spec.js deleted file mode 100644 index 56b9f2a..0000000 --- a/test/unit/controllers/example_spec.js +++ /dev/null @@ -1,30 +0,0 @@ -/*global angular */ - -'use strict'; - -describe('Unit: ExampleCtrl', function() { - - var ctrl; - - beforeEach(function() { - // instantiate the app module - angular.mock.module('app'); - - angular.mock.inject(function($controller) { - ctrl = $controller('ExampleCtrl'); - }); - }); - - it('should exist', function() { - expect(ctrl).toBeDefined(); - }); - - it('should have a number variable equal to 1234', function() { - expect(ctrl.number).toEqual(1234); - }); - - it('should have a title variable equal to \'AngularJS, Gulp, and Browserify!\'', function() { - expect(ctrl.title).toEqual('AngularJS, Gulp, and Browserify!'); - }); - -}); \ No newline at end of file diff --git a/test/unit/controllers/test-home.js b/test/unit/controllers/test-home.js new file mode 100644 index 0000000..9dd2e9e --- /dev/null +++ b/test/unit/controllers/test-home.js @@ -0,0 +1,24 @@ +/*global angular */ + +'use strict'; + +window.bootstrap && window.bootstrap(); + +describe('Unit: HomeCtrl', function() { + + var ctrl; + + beforeEach(function() { + // instantiate the app module + angular.mock.module('app'); + + angular.mock.inject(function($controller) { + ctrl = $controller('HomeCtrl'); + }); + }); + + it('should exist', function() { + expect(ctrl).toBeDefined(); + }); + +}); diff --git a/test/unit/services/example_spec.js b/test/unit/services/example_spec.js deleted file mode 100644 index 9648bba..0000000 --- a/test/unit/services/example_spec.js +++ /dev/null @@ -1,23 +0,0 @@ -/*global angular */ - -'use strict'; - -describe('Unit: ExampleService', function() { - - var service; - - beforeEach(function() { - // instantiate the app module - angular.mock.module('app'); - - // mock the service - angular.mock.inject(function(ExampleService) { - service = ExampleService; - }); - }); - - it('should exist', function() { - expect(service).toBeDefined(); - }); - -}); \ No newline at end of file diff --git a/test/unit/services/test-dataset.js b/test/unit/services/test-dataset.js new file mode 100644 index 0000000..52154c7 --- /dev/null +++ b/test/unit/services/test-dataset.js @@ -0,0 +1,69 @@ +/*global angular */ + +'use strict'; + +window.bootstrap && window.bootstrap(); + +describe('Unit: DatasetService', function() { + + var service, httpBackend; + var exampleConfig = {"tempest": [ + {"raw": "tempest_file_freshlog_0_raw.json", + "details": "tempest_file_freshlog_0_details.json", + "tree": "tempest_file_freshlog_0_tree.json", + "id": 0, + "name": "Subunit File: freshlog"} + ]}; + + beforeEach(function() { + // instantiate the app module + angular.mock.module('app'); + + // mock the service + angular.mock.inject(function(datasetService, $httpBackend) { + service = datasetService; + httpBackend = $httpBackend; + }); + }); + + it('should exist', function() { + expect(service).toBeDefined(); + }); + + it('should return config.json', function() { + httpBackend.whenGET("data/config.json").respond(exampleConfig); + service.list().then(function(config){ + expect(config.data).toEqual(exampleConfig); + }); + httpBackend.flush(); + }); + + it('should GET the raw file from a dataset', function() { + httpBackend.whenGET(exampleConfig.raw).respond(exampleConfig.raw); + service.raw(exampleConfig).then(function(raw){ + expect(raw).toEqual(exampleConfig.raw); + }); + }); + + it('should GET the details file from a dataset', function() { + httpBackend.whenGET(exampleConfig.details).respond(exampleConfig.details); + service.details(exampleConfig).then(function(details){ + expect(details).toEqual(exampleConfig.details); + }); + }); + + it('should GET the tree file from a dataset', function() { + httpBackend.whenGET(exampleConfig.tree).respond(exampleConfig.tree); + service.tree(exampleConfig).then(function(tree){ + expect(tree).toEqual(exampleConfig.tree); + }); + }); + + it('should GET the dstat file from a dataset', function() { + httpBackend.whenGET(exampleConfig.dstat).respond(exampleConfig.dstat); + service.dstat(exampleConfig).then(function(dstat){ + expect(dstat).toEqual(exampleConfig.dstat); + }); + }); + +});