Fixed license unit tests

This commit is contained in:
Michael Abashian
2017-06-23 08:37:29 -04:00
parent 2319c249c3
commit f32906287d

View File

@@ -5,7 +5,8 @@ describe('Controller: LicenseController', () => {
let scope, let scope,
LicenseController, LicenseController,
ConfigService, ConfigService,
ProcessErrors; ProcessErrors,
config;
beforeEach(angular.mock.module('Tower')); beforeEach(angular.mock.module('Tower'));
beforeEach(angular.mock.module('license', ($provide) => { beforeEach(angular.mock.module('license', ($provide) => {
@@ -14,40 +15,33 @@ describe('Controller: LicenseController', () => {
'delete' 'delete'
]); ]);
ConfigService.getConfig.and.returnValue({ config = {
then: function(callback){ license_info: {
return callback({ time_remaining: 1234567 // seconds
license_info: { },
time_remaining: 1234567 // seconds version: '3.1.0-devel'
}, };
version: '3.1.0-devel'
});
}
});
ProcessErrors = jasmine.createSpy('ProcessErrors'); ProcessErrors = jasmine.createSpy('ProcessErrors');
$provide.value('ConfigService', ConfigService); $provide.value('ConfigService', ConfigService);
$provide.value('ProcessErrors', ProcessErrors); $provide.value('ProcessErrors', ProcessErrors);
$provide.value('config', config);
})); }));
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_) => { beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_, _config_) => {
scope = $rootScope.$new(); scope = $rootScope.$new();
ConfigService = _ConfigService_; ConfigService = _ConfigService_;
ProcessErrors = _ProcessErrors_; ProcessErrors = _ProcessErrors_;
config = _config_;
LicenseController = $controller('licenseController', { LicenseController = $controller('licenseController', {
$scope: scope, $scope: scope,
ConfigService: ConfigService, ConfigService: ConfigService,
ProcessErrors: ProcessErrors ProcessErrors: ProcessErrors,
config: config
}); });
})); }));
// Suites
it('should GET a config object on initialization', ()=>{
expect(ConfigService.delete).toHaveBeenCalled();
expect(ConfigService.getConfig).toHaveBeenCalled();
});
xit('should show correct expiration date', ()=>{ xit('should show correct expiration date', ()=>{
let date = new Date(), let date = new Date(),
options = { options = {