robeaux 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gruntfile.js +43 -0
  3. data/Makefile +11 -2
  4. data/README.markdown +2 -0
  5. data/css/main.css +1 -0
  6. data/css/style.css +113 -24
  7. data/css/themes/blackboard.css +1 -0
  8. data/css/themes/dark.css +1 -0
  9. data/css/themes/gray.css +1 -0
  10. data/css/themes/whiteboard.css +1 -0
  11. data/images/bullet-connections-2.png +0 -0
  12. data/images/bullet-connections.png +0 -0
  13. data/images/bullet-devices-2.png +0 -0
  14. data/images/bullet-devices.png +0 -0
  15. data/images/devices-image-2.png +0 -0
  16. data/images/devices-image.png +0 -0
  17. data/images/logo-robeaux.png +0 -0
  18. data/images/robots-icon_03.png +0 -0
  19. data/index.html +15 -8
  20. data/js/controllers/widget_editor_ctrl.js +44 -0
  21. data/js/controllers/widgets_ctrl.js +40 -0
  22. data/js/directives/widget.js +50 -0
  23. data/js/router.js +5 -0
  24. data/js/services/themes.js +9 -5
  25. data/js/services/widgets.js +86 -0
  26. data/js/vendor/angular-route.min.js +1 -2
  27. data/js/vendor/angular.min.js +208 -206
  28. data/js/widgets/attitude.html +32 -0
  29. data/js/widgets/attitude.js +27 -0
  30. data/js/widgets/mindwave.html +51 -0
  31. data/js/widgets/mindwave.js +23 -0
  32. data/less/app.less +21 -0
  33. data/less/objects/buttons.less +32 -0
  34. data/less/objects/connections.less +28 -0
  35. data/less/objects/device.less +30 -0
  36. data/less/objects/forms.less +29 -0
  37. data/less/objects/list.less +27 -0
  38. data/less/objects/nav.less +33 -0
  39. data/less/objects/robot.less +43 -0
  40. data/less/objects/themes.less +18 -0
  41. data/less/objects/widgets.less +85 -0
  42. data/less/support/buttons.less +39 -0
  43. data/less/support/container.less +9 -0
  44. data/less/support/forms.less +18 -0
  45. data/less/support/mixins.less +3 -0
  46. data/less/themes/blackboard.less +158 -0
  47. data/less/themes/dark.less +148 -0
  48. data/less/themes/default.less +52 -0
  49. data/less/themes/gray.less +121 -0
  50. data/less/themes/whiteboard.less +152 -0
  51. data/less/vendor/elements.less +156 -0
  52. data/less/vendor/normalize.less +425 -0
  53. data/less/vendor/semantic-grid.less +67 -0
  54. data/less/views/devices.less +47 -0
  55. data/less/views/robots.less +132 -0
  56. data/less/views/themes.less +31 -0
  57. data/less/views/widgets.less +50 -0
  58. data/package.json +6 -3
  59. data/partials/device.html +66 -57
  60. data/partials/index.html +12 -6
  61. data/partials/robot.html +104 -51
  62. data/partials/themes.html +32 -29
  63. data/partials/widget_editor.html +68 -0
  64. data/robeaux.gemspec +1 -1
  65. data/test/controllers/device_commands_ctrl.js +129 -0
  66. data/test/controllers/device_events_ctrl.js +82 -0
  67. data/test/controllers/index_ctrl.js +48 -0
  68. data/test/controllers/nav_ctrl.js +40 -0
  69. data/test/controllers/robot_commands_ctrl.js +127 -0
  70. data/test/controllers/robot_ctrl.js +62 -0
  71. data/test/controllers/themes_ctrl.js +96 -0
  72. data/test/controllers/widget_editor_ctrl.js +111 -0
  73. data/test/controllers/widgets_ctrl.js +74 -0
  74. data/test/functions/functions.js +30 -0
  75. data/test/karma.conf.js +3 -7
  76. data/test/karma_test_all.conf.js +23 -0
  77. data/test/karma_test_controllers.conf.js +19 -0
  78. data/test/karma_test_functions.conf.js +14 -0
  79. data/test/karma_test_services.conf.js +17 -0
  80. data/test/services/themes.js +122 -0
  81. data/test/services/widgets.js +104 -0
  82. data/test/support/themes.json +9 -0
  83. data/test/support/widgets.json +18 -0
  84. data/test/vendor/angular-mocks.js +13 -13
  85. data/test/vendor/jquery.js +8 -8
  86. metadata +69 -3
  87. data/test/main.js +0 -248
@@ -0,0 +1,68 @@
1
+ <div class="row">
2
+ <div class="widgets">
3
+ <div class="sidebar">
4
+ <h2>Widgets</h2>
5
+
6
+ <div class="new-widget">
7
+ <input type="text" ng-model="name" placeholder="new widget name">
8
+ <button ng-click="add(name)" class="btn btn-device">add</button>
9
+ </div>
10
+
11
+ <div class="list">
12
+ <div class="widget"
13
+ ng-repeat="widget in widgets.list"
14
+ ng-click="edit(widget)"
15
+ ng-class="{selected: (editing === widget)}">
16
+ {{widget.name}}
17
+ <span class="close" ng-if="widget.custom" ng-click="widgets.remove(widget.name)">&#x2716;</span>
18
+ </div>
19
+ </div>
20
+ </div>
21
+
22
+
23
+ <div class="editor">
24
+ <div class="attrs">
25
+ <label>
26
+ <strong>Attrs:</strong>
27
+ <small>Attributes to be defined when instantiating the widget. They will be available in the script as <code>attrs</code>.</small>
28
+ </label>
29
+
30
+ <div class="attrs-list">
31
+ <span ng-repeat="attr in editing.attrs" ng-click="removeAttr($index)">
32
+ {{ attr }}
33
+ {{ $last ? '' : ', ' }}
34
+ </span>
35
+ </div>
36
+
37
+ <div class="new-attr">
38
+ <input type="text" ng-disabled="!editing" ng-model="newAttr">
39
+ <button ng-disabled="!editing" ng-click="addAttr()" class="btn btn-device">Add Attribute</button>
40
+ </div>
41
+ </div>
42
+
43
+ <div class="field">
44
+ <label>
45
+ <strong>Template:</strong>
46
+ <small>The code you put here will be used as a template for an Angular directive.</small>
47
+ </label>
48
+
49
+ <textarea id="template" ng-disabled="!editing" ng-model="editing.template" ng-blur="widgets.save()" placeholder="write your template here">
50
+ </textarea>
51
+ </div>
52
+
53
+ <div class="field">
54
+ <label>
55
+ <strong>Script:</strong>
56
+ <small>The code you put here will be used as a <code>link</code> function for an Angular directive.</small>
57
+ </label>
58
+ <textarea ng-disabled="!editing" ng-model="editing.script" ng-blur="widgets.save()" placeholder="write your javascript here">
59
+ </textarea>
60
+ </div>
61
+ </div>
62
+
63
+ <div class="footer">
64
+ <button class="btn btn-save" ng-click="widgets.save()">save</button>
65
+ <button class="btn btn-reset" ng-click="widgets.reset()">reset</button>
66
+ </div>
67
+ </div>
68
+ </div>
data/robeaux.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "robeaux"
5
- s.version = "0.2.0"
5
+ s.version = "0.3.0"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Ron Evans", "Adrian Zankich", "Ari Lerner", "Mario Ricalde", "Daniel Fischer", "Andrew Stewart"]
8
8
  s.email = ["artoo@hybridgroup.com"]
@@ -0,0 +1,129 @@
1
+ describe("Testing Controllers", function() {
2
+ describe('Controller DeviceCommandsCtrl:', function() {
3
+
4
+ beforeEach(module('robeaux'));
5
+
6
+ var $scope, $rootScope, $httpBackend, $timeout, testController;
7
+
8
+ beforeEach(inject(function($injector) {
9
+ $timeout = $injector.get('$timeout');
10
+ $httpBackend = $injector.get('$httpBackend');
11
+ $rootScope = $injector.get('$rootScope');
12
+ $scope = $rootScope.$new();
13
+
14
+ var $controller = $injector.get('$controller');
15
+
16
+ testController = function() {
17
+ return $controller('DeviceCommandsCtrl', {
18
+ '$scope': $scope
19
+ });
20
+ };
21
+ var controller = testController();
22
+
23
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
24
+
25
+ var data = loadJSONFixtures('myDevice.json')['myDevice.json'];
26
+
27
+ $scope.device = data[0];
28
+ $scope.device.results = [];
29
+ $scope.device.params = [{ name: '', value: '', type: 'string' }];
30
+ }));
31
+
32
+ afterEach(function() {
33
+ $httpBackend.verifyNoOutstandingExpectation();
34
+ $httpBackend.verifyNoOutstandingRequest();
35
+ });
36
+
37
+ describe('command:', function() {
38
+ it('should be an empty string', function (){
39
+ expect($scope.command).toBe("");
40
+ });
41
+ });
42
+
43
+ describe('command types:', function() {
44
+ it('should be an array of string, boolean and number', function (){
45
+ var command_types = [ 'string', 'boolean', 'number' ];
46
+ expect($scope.types).toEqual(command_types);
47
+ });
48
+ });
49
+
50
+ describe('isDisabled:', function() {
51
+ it('should return true if command is empty', function (){
52
+ expect($scope.isDisabled()).toBe(true);
53
+ });
54
+
55
+ it('should return false if command exist', function (){
56
+ $scope.command = 'test_command'
57
+ expect($scope.isDisabled()).toBe(false);
58
+ });
59
+ });
60
+
61
+ describe('addParam:', function() {
62
+ it('should add params if last', function (){
63
+ expect($scope.device.params.length).toBe(1)
64
+ $scope.addParam($scope.device);
65
+ expect($scope.device.params.length).toBe(2)
66
+ });
67
+
68
+ it('should not add params if not last', function (){
69
+ expect($scope.device.params.length).toBe(1)
70
+ $scope.addParam();
71
+ expect($scope.device.params.length).toBe(1)
72
+ });
73
+ });
74
+
75
+ describe('removeParam:', function() {
76
+ it('should remove param if there is more than one', function (){
77
+ $scope.device.params = [
78
+ { name: '', value: '', type: 'string' },
79
+ { name: '', value: '', type: 'string' }
80
+ ];
81
+
82
+ expect($scope.device.params.length).toBe(2)
83
+ $scope.removeParam($scope.device);
84
+ expect($scope.device.params.length).toBe(1)
85
+ });
86
+
87
+ it('should not remove param if there just one', function (){
88
+ $scope.device.params = [
89
+ { name: '', value: '', type: 'string' }
90
+ ];
91
+
92
+ expect($scope.device.params.length).toBe(1)
93
+ $scope.removeParam($scope.device);
94
+ expect($scope.device.params.length).toBe(1)
95
+ });
96
+
97
+ it('should remove the correct param passed to the function', function (){
98
+ $scope.device.params = [
99
+ { name: 'param1', value: 'value1', type: 'string' },
100
+ { name: 'param2', value: 'value2', type: 'string' }
101
+ ];
102
+
103
+ var param_to_remove = { name: 'param1', value: 'value1', type: 'string' };
104
+ var param_to_keep = { name: 'param2', value: 'value2', type: 'string' };
105
+
106
+ expect($scope.device.params[0]).toEqual(param_to_remove)
107
+ $scope.removeParam(param_to_remove);
108
+ expect($scope.device.params[0]).toEqual(param_to_keep)
109
+ });
110
+ });
111
+
112
+ describe('submit:', function() {
113
+ it('should run command and return results', function (){
114
+ $scope.robot = {'name':"myRobot"};
115
+ $scope.device.name = "led";
116
+ $scope.command = "brightness";
117
+ $scope.device.params = [{'name': 'brightness', 'value': 255, 'type':'string'}];
118
+ var params = {'brightness': 255};
119
+ var data= {'result': "brightness is 255"};
120
+
121
+ $scope.submit();
122
+ $httpBackend.expectPOST('/api/robots/myRobot/devices/led/commands/brightness', params).respond(data);
123
+ $httpBackend.flush();
124
+ expect($scope.device.results[0]).toEqual({'result': "brightness is 255"})
125
+ });
126
+ });
127
+
128
+ });
129
+ });
@@ -0,0 +1,82 @@
1
+ describe("Testing Controllers", function() {
2
+ describe('Controller DeviceEventsCtrl:', function() {
3
+
4
+ beforeEach(module('robeaux'));
5
+
6
+ var $scope, $rootScope, $httpBackend, $timeout, testController;
7
+
8
+ beforeEach(inject(function($injector) {
9
+ $timeout = $injector.get('$timeout');
10
+ $httpBackend = $injector.get('$httpBackend');
11
+ $rootScope = $injector.get('$rootScope');
12
+ $scope = $rootScope.$new();
13
+
14
+ var $controller = $injector.get('$controller');
15
+
16
+ testController = function() {
17
+ return $controller('DeviceEventsCtrl', {
18
+ '$scope': $scope
19
+ });
20
+ };
21
+ var controller = testController();
22
+
23
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
24
+
25
+ var data = loadJSONFixtures('myDevice.json')['myDevice.json'];
26
+
27
+ $scope.robot = {'name':"myRobot"};
28
+ $scope.eventName = "";
29
+ $scope.device = data[0];
30
+ $scope.device.events = null;
31
+ $scope.device.listeners = null;
32
+ }));
33
+
34
+ afterEach(function() {
35
+ $httpBackend.verifyNoOutstandingExpectation();
36
+ $httpBackend.verifyNoOutstandingRequest();
37
+ });
38
+
39
+ describe('listen:', function() {
40
+ it('should add a listener for an event and clear eventName', function (){
41
+ expect($scope.device.listeners).toBe(null);
42
+ $scope.eventName = "listen_event";
43
+ $scope.listen();
44
+ expect($scope.device.listeners['listen_event']).not.toBe(null);
45
+ expect($scope.eventName).toBe("");
46
+ });
47
+
48
+ it('should listen to multiple events', function (){
49
+ expect($scope.device.listeners).toBe(null);
50
+
51
+ $scope.eventName = "first_event";
52
+ $scope.listen();
53
+ $scope.eventName = "second_event";
54
+ $scope.listen();
55
+ $scope.eventName = "third_event";
56
+ $scope.listen();
57
+
58
+ expect($scope.device.listeners['first_event']).not.toBe(null);
59
+ expect($scope.device.listeners['second_event']).not.toBe(null);
60
+ expect($scope.device.listeners['third_event']).not.toBe(null);
61
+ });
62
+ });
63
+
64
+ describe('remove:', function() {
65
+ it('should remove listener', function (){
66
+ expect($scope.device.listeners).toBe(null);
67
+
68
+ $scope.eventName = "listen_event";
69
+ $scope.listen();
70
+ expect($scope.device.listeners['listen_event']).not.toBe(null);
71
+
72
+ $scope.remove("listen_event")
73
+
74
+ expect($scope.device.listeners['listen_event']).toBe(undefined);
75
+
76
+ });
77
+ });
78
+
79
+
80
+
81
+ });
82
+ });
@@ -0,0 +1,48 @@
1
+ describe("Testing Controllers", function() {
2
+ describe('Controller IndexCtrl:', function() {
3
+
4
+ beforeEach(module('robeaux'));
5
+
6
+ var $scope, $rootScope, $httpBackend, $location, $timeout, testController, data;
7
+
8
+ beforeEach(inject(function($injector) {
9
+ $timeout = $injector.get('$timeout');
10
+ $httpBackend = $injector.get('$httpBackend');
11
+ $rootScope = $injector.get('$rootScope');
12
+ $location = $injector.get('$location');
13
+ $scope = $rootScope.$new();
14
+
15
+ var $controller = $injector.get('$controller');
16
+
17
+ testController = function() {
18
+ return $controller('IndexCtrl', {
19
+ '$scope': $scope
20
+ });
21
+ };
22
+
23
+ var controller = testController();
24
+
25
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
26
+ data = loadJSONFixtures('robots.json')['robots.json'];
27
+ $httpBackend.expect('GET', '/api/robots').respond(data);
28
+ $httpBackend.flush();
29
+ }));
30
+
31
+ afterEach(function() {
32
+ $httpBackend.verifyNoOutstandingExpectation();
33
+ $httpBackend.verifyNoOutstandingRequest();
34
+ });
35
+
36
+ it('should get array of robots', function() {
37
+ expect($scope.robots).toEqual(data.robots);
38
+ });
39
+
40
+ describe('details:', function() {
41
+ it('should redirect to robot show page', function() {
42
+ expect($location.path()).toEqual('');
43
+ $scope.details(data.robots[0].name);
44
+ expect($location.path()).toEqual('/robots/' + data.robots[0].name);
45
+ });
46
+ });
47
+ });
48
+ });
@@ -0,0 +1,40 @@
1
+ describe("Testing Controllers", function() {
2
+ describe('Controller NavCtrl:', function() {
3
+
4
+ beforeEach(module('robeaux'));
5
+
6
+ var $scope, $rootScope, $httpBackend, $location, $timeout, testController;
7
+
8
+ beforeEach(inject(function($injector) {
9
+ $timeout = $injector.get('$timeout');
10
+ $httpBackend = $injector.get('$httpBackend');
11
+ $rootScope = $injector.get('$rootScope');
12
+ $location = $injector.get('$location');
13
+ $scope = $rootScope.$new();
14
+
15
+ var $controller = $injector.get('$controller');
16
+
17
+ testController = function() {
18
+ return $controller('NavCtrl', {
19
+ '$scope': $scope
20
+ });
21
+ };
22
+
23
+ var controller = testController();
24
+ }));
25
+
26
+ afterEach(function() {
27
+ $httpBackend.verifyNoOutstandingExpectation();
28
+ $httpBackend.verifyNoOutstandingRequest();
29
+ });
30
+
31
+ describe('active:', function() {
32
+ it('should return if current path is the same as the location path', function() {
33
+ $location.path('robots');
34
+
35
+ expect($scope.active('robots')).toEqual(true);
36
+ expect($scope.active('robots/myRobot')).toEqual(false);
37
+ });
38
+ });
39
+ });
40
+ });
@@ -0,0 +1,127 @@
1
+ describe("Testing Controllers", function() {
2
+ describe('Controller RobotCommandsCtrl:', function() {
3
+
4
+ beforeEach(module('robeaux'));
5
+
6
+ var $scope, $rootScope, $httpBackend, $timeout, $routeParams, testController;
7
+ var $injector = angular.injector(['robeaux', 'ng']);
8
+
9
+ beforeEach(inject(function($injector) {
10
+ $timeout = $injector.get('$timeout');
11
+ $httpBackend = $injector.get('$httpBackend');
12
+ $rootScope = $injector.get('$rootScope');
13
+ $routeParams = $injector.get('$routeParams');
14
+ $scope = $rootScope.$new();
15
+
16
+ var $controller = $injector.get('$controller');
17
+
18
+ testController = function() {
19
+ return $controller('RobotCommandsCtrl', {
20
+ '$scope': $scope
21
+ });
22
+ };
23
+ var controller = testController();
24
+
25
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
26
+ var data = loadJSONFixtures('myRobot.json')['myRobot.json'];
27
+ $scope.robot = data.robot;
28
+ $scope.robot.params = [ { name: '', value: '', type: 'string' } ];
29
+ $scope.robot.results = [];
30
+ }));
31
+
32
+ afterEach(function() {
33
+ $httpBackend.verifyNoOutstandingExpectation();
34
+ $httpBackend.verifyNoOutstandingRequest();
35
+ });
36
+
37
+ describe('command:', function() {
38
+ it('should be an empty string', function (){
39
+ expect($scope.command).toBe("");
40
+ });
41
+ });
42
+
43
+ describe('command types:', function() {
44
+ it('should be an array of string, boolean and number', function (){
45
+ var command_types = [ 'string', 'boolean', 'number' ];
46
+ expect($scope.types).toEqual(command_types);
47
+ });
48
+ });
49
+
50
+ describe('isDisabled:', function() {
51
+ it('should return true if command is empty', function (){
52
+ expect($scope.isDisabled()).toBe(true);
53
+ });
54
+
55
+ it('should return false if command exist', function (){
56
+ $scope.command = 'test_command'
57
+ expect($scope.isDisabled()).toBe(false);
58
+ });
59
+ });
60
+
61
+ describe('addParam:', function() {
62
+ it('should add params if last', function (){
63
+ expect($scope.robot.params.length).toBe(1)
64
+ $scope.addParam($scope.robot);
65
+ expect($scope.robot.params.length).toBe(2)
66
+ });
67
+
68
+ it('should not add params if not last', function (){
69
+ expect($scope.robot.params.length).toBe(1)
70
+ $scope.addParam();
71
+ expect($scope.robot.params.length).toBe(1)
72
+ });
73
+ });
74
+
75
+ describe('removeParam:', function() {
76
+ it('should remove param if there is more than one', function (){
77
+ $scope.robot.params = [
78
+ { name: '', value: '', type: 'string' },
79
+ { name: '', value: '', type: 'string' }
80
+ ];
81
+
82
+ expect($scope.robot.params.length).toBe(2)
83
+ $scope.removeParam($scope.robot);
84
+ expect($scope.robot.params.length).toBe(1)
85
+ });
86
+
87
+ it('should not remove param if there just one', function (){
88
+ $scope.robot.params = [
89
+ { name: '', value: '', type: 'string' }
90
+ ];
91
+
92
+ expect($scope.robot.params.length).toBe(1)
93
+ $scope.removeParam($scope.robot);
94
+ expect($scope.robot.params.length).toBe(1)
95
+ });
96
+
97
+ it('should remove the correct param passed to the function', function (){
98
+ $scope.robot.params = [
99
+ { name: 'param1', value: 'value1', type: 'string' },
100
+ { name: 'param2', value: 'value2', type: 'string' }
101
+ ];
102
+
103
+ var param_to_remove = { name: 'param1', value: 'value1', type: 'string' };
104
+ var param_to_keep = { name: 'param2', value: 'value2', type: 'string' };
105
+
106
+ expect($scope.robot.params[0]).toEqual(param_to_remove)
107
+ $scope.removeParam(param_to_remove);
108
+ expect($scope.robot.params[0]).toEqual(param_to_keep)
109
+ });
110
+ });
111
+
112
+ describe('submit:', function() {
113
+ it('should run command and return results', function (){
114
+ $scope.robot.name = "myRobot";
115
+ $scope.command = "relax";
116
+ $scope.robot.params= [{'name': 'relax', 'value':'true', 'type':'string'}];
117
+ var params = {'relax': 'true'};
118
+ var data= {'result': "myRobot says relax"};
119
+
120
+ $scope.submit();
121
+ $httpBackend.expectPOST('/api/robots/myRobot/commands/relax', params).respond(data);
122
+ $httpBackend.flush();
123
+ expect($scope.robot.results).toEqual([{'result': "myRobot says relax"}])
124
+ });
125
+ });
126
+ });
127
+ });
@@ -0,0 +1,62 @@
1
+ describe("Testing Controllers", function() {
2
+ describe('Controller RobotCtrl:', function() {
3
+
4
+ beforeEach(module('robeaux'));
5
+
6
+ var $scope, $rootScope, $httpBackend, $timeout, $routeParams, testController;
7
+
8
+ beforeEach(inject(function($injector) {
9
+ $timeout = $injector.get('$timeout');
10
+ $httpBackend = $injector.get('$httpBackend');
11
+ $rootScope = $injector.get('$rootScope');
12
+ $routeParams = $injector.get('$routeParams');
13
+ $scope = $rootScope.$new();
14
+
15
+ var $controller = $injector.get('$controller');
16
+
17
+ testController = function() {
18
+ return $controller('RobotCtrl', {
19
+ '$scope': $scope
20
+
21
+ });
22
+ };
23
+ var controller = testController();
24
+
25
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
26
+ $httpBackend.expect('GET', '/api/robots/' + $routeParams.robot).respond(loadJSONFixtures('myRobot.json')['myRobot.json']);
27
+ $httpBackend.flush();
28
+
29
+ }));
30
+
31
+ afterEach(function() {
32
+ $httpBackend.verifyNoOutstandingExpectation();
33
+ $httpBackend.verifyNoOutstandingRequest();
34
+ });
35
+
36
+ it('should get robot details', function() {
37
+ var data = loadJSONFixtures('myRobot.json')['myRobot.json'];
38
+ data.robot.params = [ { name: '', value: '', type: 'string' } ];
39
+ data.robot.results = [];
40
+ expect($scope.robot).toEqual(data.robot);
41
+ });
42
+
43
+ describe('select:', function() {
44
+ it('should select a device', function (){
45
+ var robotArray= [{"name": "robo1"},{"name":"robo2"}];
46
+ $scope.robot = robotArray;
47
+ $scope.select($scope.robot[1]);
48
+ expect($scope.robot[1]).toEqual($scope.device);
49
+ expect($scope.robot[0]).toNotEqual($scope.device);
50
+ });
51
+ });
52
+
53
+ describe('selected:', function() {
54
+ it('should return if device is still selected', function (){
55
+ var robotArray= [{"name": "robo1"},{"name":"robo2"}];
56
+ $scope.robot = robotArray;
57
+ $scope.select($scope.robot);
58
+ expect($scope.selected($scope.robot)).toBeTruthy();
59
+ });
60
+ });
61
+ });
62
+ });
@@ -0,0 +1,96 @@
1
+ describe("Testing Controllers", function() {
2
+ describe('Controller ThemesCtrl:', function() {
3
+
4
+ beforeEach(module('robeaux'));
5
+
6
+ var $scope, $rootScope, $httpBackend, $timeout, $routeParams, testController, data;
7
+
8
+ beforeEach(inject(function($injector) {
9
+ localStorage.clear();
10
+ $timeout = $injector.get('$timeout');
11
+ $httpBackend = $injector.get('$httpBackend');
12
+ $rootScope = $injector.get('$rootScope');
13
+ $routeParams = $injector.get('$routeParams');
14
+ $scope = $rootScope.$new();
15
+ $scope.themes = $injector.get('Themes')
16
+
17
+ var $controller = $injector.get('$controller');
18
+
19
+ testController = function() {
20
+ return $controller('ThemesCtrl', {
21
+ '$scope': $scope
22
+
23
+ });
24
+ };
25
+ var controller = testController();
26
+ jasmine.getJSONFixtures().fixturesPath='base/test/support';
27
+ data = loadJSONFixtures('themes.json')['themes.json'];
28
+
29
+ }));
30
+
31
+ afterEach(function() {
32
+ $scope.themes = null;
33
+ $httpBackend.verifyNoOutstandingExpectation();
34
+ $httpBackend.verifyNoOutstandingRequest();
35
+ });
36
+
37
+ it('should get array of themes', function() {
38
+ expect($scope.themes.list).toEqual(data.themes);
39
+ });
40
+
41
+ describe('add:', function() {
42
+ it('should not add theme with empty name', function() {
43
+ expect($scope.themes.list.length).toEqual(5);
44
+ $scope.add('');
45
+ expect($scope.themes.list.length).toEqual(5);
46
+ $scope.add();
47
+ expect($scope.themes.list.length).toEqual(5);
48
+ });
49
+
50
+ it('should not add theme if name already exist', function() {
51
+ expect($scope.themes.list.length).toEqual(5);
52
+ $scope.add('artoo');
53
+ expect($scope.themes.list.length).toEqual(5);
54
+ });
55
+
56
+ it('should add theme', function() {
57
+ expect($scope.themes.list.length).toEqual(5);
58
+ $scope.add('first theme');
59
+ expect($scope.themes.list.length).toEqual(6);
60
+ });
61
+
62
+ it('should add theme and put it on edit mode', function() {
63
+ expect($scope.editing).toEqual(null);
64
+ $scope.add('second theme');
65
+ expect($scope.editing.name).toEqual('second theme');
66
+ });
67
+ });
68
+
69
+ describe('edit:', function() {
70
+ it('should not set theme on edit mode if is not a custom theme', function() {
71
+ expect($scope.editing).toEqual(null);
72
+ $scope.edit(data.themes[0].name)
73
+ expect($scope.editing).toEqual(null);
74
+ });
75
+
76
+ it('should not set theme on edit mode if theme is already being edited', function() {
77
+ expect($scope.editing).toEqual(null);
78
+ $scope.add('third theme')
79
+ expect($scope.editing.name).toEqual('third theme');
80
+
81
+ $scope.edit('third theme');
82
+ expect($scope.editing).toEqual(null);
83
+ });
84
+ });
85
+
86
+ describe('remove:', function() {
87
+ it('should remove theme', function() {
88
+ expect($scope.themes.list.length).toEqual(5);
89
+ $scope.remove('artoo');
90
+ expect($scope.themes.list.length).toEqual(4);
91
+ });
92
+ });
93
+
94
+
95
+ });
96
+ });