Is it standard behavior to assign singleton variables (used only in unit testing) in a controller?

"myEvent" is fired when clicking on any div in a grid,

watching this event using:

$scope.$on('myEvent', function (e, info) {
    var someString = someStringHelper.convertToString(info);
    $scope.justToTest = someString;
    // Do stuff.

And it looks like someone is using $scope.justToTest as follows:

it('should handle myEvent events', function () {
    childScope.$apply(function () {
        childScope.$emit('myEvent', new generateStringKey("a", b, c));


No, I would not say it is typical (or a good idea) to have properties on the scope that are not needed.

For this specific example, it is fine for the test to fire the event, but the test should be testing the effect of the event on 'real' properties that are used.

So, the overall structure of the test looks correct. But the expectation should only apply to scope.stringsList. And justForTest should be taken out.

Need Your Help

lazy loading angularjs controllers with ui-router resolve

angularjs requirejs angular-ui-router

I'm trying to get to work angular.js, ui-router, and require.js and feel quite confused. I tried to follow this tutorial First, let me show you my code:

Cross Domain jQuery Ajax call - Syntax missing error

php jquery ajax

I couldn't access the webservice call from cross domain. Please advice. I have pasted my source here.