Added a test that point to the desired beahviour, now it's failing
diff --git a/xos-apps/auto-scale/gui/spec/.eslintrc b/xos-apps/auto-scale/gui/spec/.eslintrc
new file mode 100644
index 0000000..ad4bc2d
--- /dev/null
+++ b/xos-apps/auto-scale/gui/spec/.eslintrc
@@ -0,0 +1,9 @@
+{
+ "globals" :{
+ "describe": true,
+ "beforeEach": true,
+ "it": true,
+ "inject": true,
+ "expect": true
+ }
+}
diff --git a/xos-apps/auto-scale/gui/spec/autoscaling.test.js b/xos-apps/auto-scale/gui/spec/autoscaling.test.js
new file mode 100644
index 0000000..54caf0e
--- /dev/null
+++ b/xos-apps/auto-scale/gui/spec/autoscaling.test.js
@@ -0,0 +1,48 @@
+'use strict';
+
+describe('In autoscaling app', () => {
+ var scope, element, vm, httpBackend, Service;
+
+
+
+ beforeEach(module('autoscaling'));
+ beforeEach(module('templates'));
+
+ beforeEach(inject(($httpBackend, $rootScope, Autoscaling) => {
+ httpBackend = $httpBackend;
+ scope = $rootScope.$new();
+ Service = Autoscaling;
+ }));
+
+ describe('the serviceContainer', () => {
+ beforeEach(inject(function($httpBackend, $compile){
+
+ httpBackend.whenGET('/autoscaledata').respond(200, autoscalingMock);
+
+ element = angular.element('<service-container></service-container>');
+ $compile(element)(scope);
+
+ scope.$digest();
+ vm = element.isolateScope().vm;
+ httpBackend.flush();
+ }));
+
+ it('should correctly format data', () => {
+ expect(vm.services['service1']).toBeDefined();
+ expect(vm.services['service1']['slice1']).toBeDefined();
+ expect(vm.services['service1']['slice1']['instance1']).toBeDefined();
+
+ expect(vm.services['service1']['slice1']['instance1'][0].counter_volume).toBe(10);
+ expect(vm.services['service1']['slice1']['instance1'][1].counter_volume).toBe(11);
+
+ // triggering the function with 2 resources
+ vm.printData(Service.formatData(autoscalingMock2instances));
+
+ const keys = Object.keys(vm.services['service1']['slice1']);
+
+ expect(vm.services['service1']['slice1'][keys[0]][0].counter_volume).toBe(10);
+ expect(vm.services['service1']['slice1'][keys[0]][1].counter_volume).toBe(11);
+
+ });
+ });
+});
\ No newline at end of file
diff --git a/xos-apps/auto-scale/gui/spec/autoscaling_data.mock.js b/xos-apps/auto-scale/gui/spec/autoscaling_data.mock.js
new file mode 100644
index 0000000..e9f637a
--- /dev/null
+++ b/xos-apps/auto-scale/gui/spec/autoscaling_data.mock.js
@@ -0,0 +1,64 @@
+var autoscalingMock =[
+ {
+ 'slice': 'slice1',
+ 'service': 'service1',
+ 'project_id': 'project1',
+ 'resources': {
+ 'resource1': {
+ 'queue': [
+ {
+ 'timestamp': '2015-12-17T22:55:36Z',
+ 'counter_volume': 10,
+ },
+ {
+ 'timestamp': '2015-12-17T22:55:46Z',
+ 'counter_volume': 11,
+ }
+ ],
+ 'xos_instance_info': {
+ 'instance_name': 'instance1'
+ }
+ }
+ }
+ }
+];
+
+var autoscalingMock2instances =[
+ {
+ 'slice': 'slice1',
+ 'service': 'service1',
+ 'project_id': 'project1',
+ 'resources': {
+ 'resource2': {
+ 'queue': [
+ {
+ 'timestamp': '2015-12-17T22:55:36Z',
+ 'counter_volume': 20,
+ },
+ {
+ 'timestamp': '2015-12-17T22:55:46Z',
+ 'counter_volume': 21,
+ }
+ ],
+ 'xos_instance_info': {
+ 'instance_name': 'instance2'
+ }
+ },
+ 'resource1': {
+ 'queue': [
+ {
+ 'timestamp': '2015-12-17T22:55:36Z',
+ 'counter_volume': 10,
+ },
+ {
+ 'timestamp': '2015-12-17T22:55:46Z',
+ 'counter_volume': 11,
+ }
+ ],
+ 'xos_instance_info': {
+ 'instance_name': 'instance1'
+ }
+ },
+ }
+ }
+];
\ No newline at end of file