Skip to content

Commit

Permalink
Merge pull request ConnectedMachines#39 from mLuby/master
Browse files Browse the repository at this point in the history
test coverage for MasterController.js
  • Loading branch information
Mike Luby committed Oct 8, 2014
2 parents 1786e4b + a2aa160 commit 5dd43cf
Showing 1 changed file with 76 additions and 15 deletions.
91 changes: 76 additions & 15 deletions client/app.spec.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,83 @@
'use strict';

describe('Client', function(){
it('exists', function(){
expect(angular.module('MadProps')).toBeDefined();
});
// describe('Client', function(){
// it('exists', function(){
// expect(angular.module('MadProps')).toBeDefined();
// });

describe('About', function(){
it('Route exists', function () {
var wasRouteFound = false;
var configBlocks = angular.module('MadProps')._configBlocks;
configBlocks.forEach(function(configBlock){
if(configBlock[2][0].toString().indexOf("url:'/about'") >= 0){
wasRouteFound = true;
}
// describe('About', function(){
// it('Route exists', function () {
// var wasRouteFound = false;
// var configBlocks = angular.module('MadProps')._configBlocks;
// configBlocks.forEach(function(configBlock){
// if(configBlock[2][0].toString().indexOf("url:'/about'") >= 0){
// wasRouteFound = true;
// }
// });
// expect(wasRouteFound).toBe(true);
// });
// xit('Navigating to /about triggers this route.', function(){
// });
// });
// });

describe('Client', function() {
beforeEach(module('MadProps'));

describe('AppController', function () {
var controller, scope;
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
controller = $controller('AppController', {
$scope: scope
});
}));
it('exists', function() {
expect(controller).toBeDefined();
});
});

describe('cardController', function () {
var controller, scope;
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
controller = $controller('cardController', {
$scope: scope
});
}));
it('has settings', function() {
expect(scope.settings).toBeDefined();
});
});

describe('MasterController', function() {
beforeEach(module('MadProps'));
var MasterController, scope, rootScope;
beforeEach(inject(function($controller, $rootScope) {
rootScope = $rootScope;
scope = $rootScope.$new();
MasterController = $controller('MasterController', {
$scope: scope
});
expect(wasRouteFound).toBe(true);
}));
it('on socket:droneData, only if both loaded flags are true, then broadcasts.', function () {
spyOn(scope, '$broadcast');
var broadcastingScope = scope.$parent;
broadcastingScope.$broadcast('socket:droneData', data);
expect(scope.$broadcast).not.toHaveBeenCalledWith('throttleData', undefined);
expect(scope.$broadcast).not.toHaveBeenCalledWith('attitudeData', undefined);
broadcastingScope.$broadcast('d3Loaded');
broadcastingScope.$broadcast('threeLoaded');
var data = JSON.stringify('{attitude: 0, motorThrottles: 0}');
broadcastingScope.$broadcast('socket:droneData', data);
expect(scope.$broadcast).toHaveBeenCalledWith('throttleData', undefined);
expect(scope.$broadcast).toHaveBeenCalledWith('attitudeData', undefined);
});
xit('Navigating to /about triggers this route.', function(){

it('has listeners on \'d3Loaded\', \'threeLoaded\', and \'socket:droneData\'', function(){
expect(scope.$$listeners.d3Loaded).toBeDefined();
expect(scope.$$listeners.threeLoaded).toBeDefined();
expect(scope.$$listeners['socket:droneData']).toBeDefined();
});
});
});
});

0 comments on commit 5dd43cf

Please sign in to comment.