Update unit tests

This commit is contained in:
Frédéric Vachon 2015-01-16 16:35:27 -05:00
parent ef82918191
commit a638ec445e
5 changed files with 144 additions and 17 deletions

View File

@ -1,18 +1,43 @@
'use strict'; 'use strict';
describe('Navbar module', function () { describe('Navbar module', function () {
var $compile,
$rootScope,
$controller,
$httpBackend;
beforeEach(module('adagios.navbar')); beforeEach(module('adagios.navbar'));
beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
$controller = _$controller_;
$httpBackend = _$httpBackend_;
$httpBackend.expectGET('navbar/navbar.html').respond('<a>{{ notifications }}</a>');
}));
describe('NavBarCtrl', function () { describe('NavBarCtrl', function () {
it('should be defined', inject(function ($controller) { it('should be defined', function () {
var scope, ctrl; var scope = $rootScope.$new(),
scope = {}; navbar = $controller('NavBarCtrl', { $scope : scope });
ctrl = $controller('NavBarCtrl', { $scope : scope });
expect(ctrl).toBeDefined(); expect(navbar).toBeDefined();
})); });
});
describe('Navbar directive', function () {
it('should insert the number of warnings', function () {
var element = $compile('<navbar></navbar>')($rootScope);
$httpBackend.flush();
$rootScope.notifications = 44;
$rootScope.$digest();
expect(element.text()).toBe('44');
});
}); });
}); });

View File

@ -1,18 +1,41 @@
'use strict'; 'use strict';
describe('Sidebar module', function () { describe('Sidebar module', function () {
var $compile,
$rootScope,
$controller,
$httpBackend;
beforeEach(module('adagios.sidebar')); beforeEach(module('adagios.sidebar'));
beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
$controller = _$controller_;
$httpBackend = _$httpBackend_;
$httpBackend.expectGET('sidebar/sidebar.html').respond('<li></li>');
}));
describe('SideBarCtrl', function () { describe('SideBarCtrl', function () {
it('should be defined', inject(function ($controller) { it('should be defined', function () {
var scope, ctrl; var scope = $rootScope.$new(),
scope = {}; ctrl = $controller('SideBarCtrl', { $scope : scope });
ctrl = $controller('SideBarCtrl', { $scope : scope });
expect(ctrl).toBeDefined(); expect(ctrl).toBeDefined();
})); });
});
describe('Sidebar directive', function () {
it('should send a GET request', function () {
var element = $compile('<sidebar></sidebar>')($rootScope);
$httpBackend.flush();
expect(element.html()).toBe('<li></li>');
});
}); });
}); });

View File

@ -1,18 +1,43 @@
'use strict'; 'use strict';
describe('Current Health tactical submodule', function () { describe('Current Health tactical submodule', function () {
var $compile,
$rootScope,
$controller,
$httpBackend;
beforeEach(module('adagios.tactical.current_health')); beforeEach(module('adagios.tactical.current_health'));
beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
$controller = _$controller_;
$httpBackend = _$httpBackend_;
$httpBackend.expectGET('tactical/current_health/current_health.html')
.respond('<th>Current Health</th>');
}));
describe('TacticalCurrentHealth', function () { describe('TacticalCurrentHealth', function () {
it('should be defined', inject(function ($controller) { it('should be defined', function () {
var scope, ctrl; var scope, ctrl;
scope = {}; scope = {};
ctrl = $controller('TacticalCurrentHealth', { $scope : scope }); ctrl = $controller('TacticalCurrentHealth', { $scope : scope });
expect(ctrl).toBeDefined(); expect(ctrl).toBeDefined();
})); });
});
describe('Current health directive', function () {
it('should send a GET request', function () {
var element = $compile("<currenthealth></currenthealth>")($rootScope);
$httpBackend.flush();
expect(element.text()).toBe('Current Health');
});
}); });
}); });

View File

@ -1,18 +1,45 @@
'use strict'; 'use strict';
describe('Status Overview tactical submodule', function () { describe('Status Overview tactical submodule', function () {
var $compile,
$rootScope,
$controller,
$httpBackend;
beforeEach(module('adagios.tactical.status_overview')); beforeEach(module('adagios.tactical.status_overview'));
beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
$controller = _$controller_;
$httpBackend = _$httpBackend_;
$httpBackend.expectGET('tactical/status_overview/status_overview.html')
.respond('<td>{{ problems }}</td>');
}));
describe('TacticalStatusOverViewCtrl', function () { describe('TacticalStatusOverViewCtrl', function () {
it('should be defined', inject(function ($controller) { it('should be defined', function () {
var scope, ctrl; var scope, ctrl;
scope = {}; scope = {};
ctrl = $controller('TacticalStatusOverViewCtrl', { $scope : scope }); ctrl = $controller('TacticalStatusOverViewCtrl', { $scope : scope });
expect(ctrl).toBeDefined(); expect(ctrl).toBeDefined();
})); });
});
describe('Status overview directive', function () {
it('should insert the number of warnings', function () {
var element = $compile('<statusoverview></statusoverview>')($rootScope);
$httpBackend.flush();
$rootScope.problems = 31;
$rootScope.$digest();
expect(element.text()).toBe('31');
});
}); });
}); });

View File

@ -1,18 +1,45 @@
'use strict'; 'use strict';
describe('Top Alert Producer tactical submodule', function () { describe('Top Alert Producer tactical submodule', function () {
var $compile,
$rootScope,
$controller,
$httpBackend;
beforeEach(module('adagios.tactical.top_alert_producers')); beforeEach(module('adagios.tactical.top_alert_producers'));
beforeEach(inject(function (_$compile_, _$rootScope_, _$controller_, _$httpBackend_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
$controller = _$controller_;
$httpBackend = _$httpBackend_;
$httpBackend.expectGET('tactical/top_alert_producers/top_alert_producers.html')
.respond('<td>{{ problems }}</td>');
}));
describe('TacticalTopAlertProducers', function () { describe('TacticalTopAlertProducers', function () {
it('should be defined', inject(function ($controller) { it('should be defined', function () {
var scope, ctrl; var scope, ctrl;
scope = {}; scope = {};
ctrl = $controller('TacticalTopAlertProducers', { $scope : scope }); ctrl = $controller('TacticalTopAlertProducers', { $scope : scope });
expect(ctrl).toBeDefined(); expect(ctrl).toBeDefined();
})); });
});
describe('Status overview directive', function () {
it('should insert the number of warnings', function () {
var element = $compile('<topalertproducers></topalertproducers>')($rootScope);
$httpBackend.flush();
$rootScope.problems = 31;
$rootScope.$digest();
expect(element.text()).toBe('31');
});
}); });
}); });