test(hintCtrl): implement test for suppressing messages

test-unit-sauce
Carlo s A. Guillen 10 years ago
parent 03bef161b5
commit 97380e8fcc

@ -76,12 +76,15 @@ angular.module('ngHintUI')
var endInd = 60;
while(message.charAt(endInd) !== ' ') {
endInd++;
if(endInd > 75) {
break;
}
}
$scope.suppressedMessages[key] = '...'+message.substring(secondSpace,endInd)+'...';
$scope.suppressedMessages[key] = '...'+message.substring(secondSpace+1,endInd)+'...';
};
$scope.unsuppressMessage = function(message) {
$scope.unsuppressMessage = function(messageKey) {
$scope.suppressedMessagesLength--;
delete $scope.suppressedMessages[message];
delete $scope.suppressedMessages[messageKey];
}
}]);

@ -172,21 +172,48 @@ describe('angularHint', function() {
//TO DO CARLOS WHO WROTE THESE METHODS
describe('message suppression', function() {
describe('isSuppressed', function() {
it('should detect if a message is currently suppressed', function() {
//TO DO
});
});
describe('suppressMessage', function() {
it('should put a message into the list of suppressedMessages', function() {
var scope = $rootScope.$new();
var ctrl = $controller('HintController', {$scope: scope});
scope.suppressMessage('an error message that will be suppressed and hid from display and yay');
expect(scope.suppressedMessages['suppressedandhid']).toEqual('...error message that will be suppressed and hid from display...');
});
it('should increment suppressedMessagesLength', function() {
var scope = $rootScope.$new();
var ctrl = $controller('HintController', {$scope: scope});
scope.suppressMessage('an error message that should increment the counter of messages and yay');
expect(scope.suppressedMessagesLength).toBe(1);
});
});
describe('unsuppressMessage', function() {
it('should remove a message from the list of suppressedMessages', function() {
it('should remove a message into the list of suppressedMessages', function() {
var scope = $rootScope.$new();
var ctrl = $controller('HintController', {$scope: scope});
scope.suppressMessage('an error message that will be suppressed and hid from display and yay');
scope.unsuppressMessage('suppressedandhid');
expect(scope.suppressedMessages['suppressedandhid']).toBeUndefined();
});
it('should decrement suppressedMessagesLength', function() {
var scope = $rootScope.$new();
var ctrl = $controller('HintController', {$scope: scope});
scope.suppressMessage('an error message that should increment the counter of messages');
scope.unsuppressMessage('suppressedandhid');
expect(scope.suppressedMessagesLength).toBe(0);
});
});
describe('isSuppressed', function() {
it('should detect if a message is currently suppressed', function() {
var scope = $rootScope.$new();
var ctrl = $controller('HintController', {$scope: scope});
scope.suppressMessage('an error message that will be suppressed and hid from display');
var res = scope.isSuppressed('an error message that will be suppressed and hid from display');
expect(res).toBe(true);
res = scope.isSuppressed('this is an error message that has not ever been suppressed');
expect(res).toBe(false);
});
});
});

@ -4,16 +4,14 @@
"description": "chrome extension for inspecting angular apps",
"main": "hint.js",
"devDependencies": {
"karma": "0.12.16",
"karma-bro": "^0.6.0",
"karma-jasmine": "0.1.5"
"karma-chrome-launcher": "^0.1.4",
"karma-jasmine": "^0.1.5"
},
"dependencies": {
"browserify": "^5.9.1",
"gulp": "^3.8.7",
"vinyl-source-stream": "^0.1.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "browserify hint.js -o hint.bundle.js"