Fix js test

To fix error on js test, switch test browser from phantom-js to chrome.
Also, this fixes existing tests.

Change-Id: Ia9e97486976a596752df2e44538774e0ff6d13cc
This commit is contained in:
Shu Muto 2017-09-04 18:21:47 +09:00
parent 1ca7eca42a
commit 7a6d375b54
5 changed files with 24 additions and 31 deletions

View File

@ -20,9 +20,7 @@
"karma-coverage": "1.1.1",
"karma-jasmine": "1.0.2",
"karma-ng-html2js-preprocessor": "1.0.0",
"karma-phantomjs-launcher": "0.2.0",
"karma-threshold-reporter": "0.1.15",
"phantomjs": "1.9.17"
"karma-threshold-reporter": "0.1.15"
},
"dependencies": {},
"scripts": {

View File

@ -119,20 +119,14 @@ module.exports = function (config) {
frameworks: ['jasmine'],
browsers: ['PhantomJS'],
browsers: ['Chrome'],
browserNoActivityTimeout: 60000,
phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered
// (useful if karma exits without killing phantom)
exitOnResourceError: true
},
reporters: ['progress', 'coverage', 'threshold'],
plugins: [
'karma-phantomjs-launcher',
'karma-chrome-launcher',
'karma-jasmine',
'karma-ng-html2js-preprocessor',
'karma-coverage',

View File

@ -25,7 +25,7 @@
angular.module('horizon.dashboard.project.queues.actions', [
'horizon.framework.conf',
'horizon.app.core'])
.run(registerActions);
.run(registerActions);
registerActions.$inject = [
'horizon.framework.conf.resource-type-registry.service',

View File

@ -26,7 +26,7 @@
* Controller for the messages table
*/
angular
.module('horizon.dashboard.project.queues.actions')
.module('horizon.dashboard.project.queues')
.controller('horizon.dashboard.project.queues.actions.messageController',
messageController);
@ -45,7 +45,7 @@
ctrl.deleteMessage = deleteMessage;
*/
zaqar.getMessages(ctrl.queue).success(function (response) {
zaqar.getMessages(ctrl.queue).then(function (response) {
ctrl.messages = response;
});

View File

@ -15,39 +15,40 @@
(function() {
'use strict';
describe('horizon.dashboard.project.queues.actions.messageController', function() {
var zaqar, controller, $scope, $q, deferred;
var zaqar, ctrl, $scope, $q, deferred;
beforeEach(module('horizon.framework'));
beforeEach(module('horizon.app.core.openstack-service-api'));
beforeEach(module('horizon.dashboard.project.queues'));
beforeEach(inject(function ($injector, _$rootScope_) {
beforeEach(inject(function ($injector, $controller, _$rootScope_, _$q_) {
$q = _$q_;
$scope = _$rootScope_.$new();
$scope.model = {
id: ''
id: '1'
};
zaqar = $injector.get('horizon.app.core.openstack-service-api.zaqar');
controller = $injector.get('$controller');
controller(
deferred = $q.defer();
deferred.resolve([{id: '1'}]);
spyOn(zaqar, 'getMessages').and.returnValue(deferred.promise);
ctrl = $controller(
'horizon.dashboard.project.queues.actions.messageController',
{
$scope: $scope,
zaqar: zaqar
});
deferred = $q.defer();
deferred.resolve({data: {id: '1'}});
spyOn(zaqar, 'getMessages').and.returnValue(deferred.promise);
asdf();
'$scope': $scope,
'horizon.app.core.openstack-service-api.zaqar': zaqar
}
);
}));
it('should load messages for queue', function() {
expect(zaqar.getMessages).toHaveBeenCalled();
it('should queue_id is provided by scope variable', function() {
expect(ctrl.queue).toBe('1');
});
it('should queue_id is provided by scope variable', function() {
$scope.model.id = '1';
it('should load messages for queue', function() {
$scope.$apply();
expect($scope.model.id).toBe('1');
expect(zaqar.getMessages).toHaveBeenCalled();
expect(ctrl.messages.length).toBe(1);
});
});
})();