← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21139: Reformatted the tests

 

------------------------------------------------------------
revno: 21139
committer: Jiju K Jose <jijukjose@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-11-20 09:39:32 +0100
message:
  Reformatted the tests
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js	2015-11-19 14:20:27 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js	2015-11-20 08:39:32 +0000
@@ -1,72 +1,76 @@
-const {module, inject} = angular.mock;
-const {spy} = sinon;
-
-describe('Directives: d2SetFocus', () => {
-    let mock$scope;
-    let element;
-    let $timeout;
-    let render;
-    beforeEach(module('d2Directives'));
-    beforeEach(inject(($injector) => {
-        const $compile = $injector.get('$compile');
-        const $rootScope = $injector.get('$rootScope');
-        $timeout = $injector.get('$timeout');
-        mock$scope = $rootScope.$new();
-        mock$scope.isFocused = false;
-        render = (elm) =>
-        {
-            elm[0].focus = spy();
-            $compile(elm)(mock$scope);
-            mock$scope.$digest();
-            $timeout.flush();
-        };
-    }));
-
-    it('should set the focus when the attribute property is set to true', () => {
-        var elm = angular.element('<input d2-set-focus="true" />');
-        render(elm);
-        expect(elm[0].focus).to.be.calledOnce;
-    });
-
-    it('should not set focus when the attribute property is set to false', () => {
-        var elm = angular.element('<input d2-set-focus="false" />');
-        render(elm);
-        expect(elm[0].focus).to.not.be.called;
-    });
-});
-
-
-describe('Directives: d2Enter', () => {
-    let mock$scope;
-    let element;
-    let $timeout;
-    let render;
-
-    beforeEach(module('d2Directives'));
-
-
-    beforeEach(inject(($injector) => {
-        const $compile = $injector.get('$compile');
-        const $rootScope = $injector.get('$rootScope');
-        $timeout = $injector.get('$timeout');
-        mock$scope = $rootScope.$new();
-        mock$scope.search = function() {
-            var a=100;
-        };
-        mock$scope.message="testMessage";
-        render = (elm) => {
-            mock$scope.search = spy();
-            $compile(elm)(mock$scope);
-            mock$scope.$digest();
-        };
-    }));
-
-    it('should call the resgistered function on key press event', () => {
-        var elm = angular.element('<input type="text" d2-enter="search(message)"/>');
-        render(elm);
-        var e = jQuery.Event("keydown");
-        e.which = 13; // # Some key code value
-        elm .trigger(e);
-        expect(mock$scope.search).to.be.calledOnce;
+describe('Directives: d2Drirectives', () => {
+
+    const {module, inject} = angular.mock;
+    const {spy} = sinon;
+    beforeEach(module('d2Directives'));
+
+    describe('Directive: d2SetFocus', () => {
+        let mock$scope;
+        let element;
+        let $timeout;
+        let render;
+
+        beforeEach(inject(($injector) => {
+            const $compile = $injector.get('$compile');
+            const $rootScope = $injector.get('$rootScope');
+            $timeout = $injector.get('$timeout');
+            mock$scope = $rootScope.$new();
+            mock$scope.isFocused = false;
+            render = (elm) =>
+            {
+                elm[0].focus = spy();
+                $compile(elm)(mock$scope);
+                mock$scope.$digest();
+                $timeout.flush();
+            };
+        }));
+
+        it('should set the focus when the attribute property is set to true', () => {
+            var elm = angular.element('<input d2-set-focus="true" />');
+            render(elm);
+            expect(elm[0].focus).to.be.calledOnce;
+        });
+
+        it('should not set focus when the attribute property is set to false', () => {
+            var elm = angular.element('<input d2-set-focus="false" />');
+            render(elm);
+            expect(elm[0].focus).to.not.be.called;
+        });
+    });
+
+
+    describe('Directive: d2Enter', () => {
+        let mock$scope;
+        let element;
+        let $timeout;
+        let render;
+
+
+
+
+        beforeEach(inject(($injector) => {
+            const $compile = $injector.get('$compile');
+            const $rootScope = $injector.get('$rootScope');
+            $timeout = $injector.get('$timeout');
+            mock$scope = $rootScope.$new();
+            mock$scope.search = function() {
+
+            };
+            mock$scope.message="testMessage";
+            render = (elm) => {
+                mock$scope.search = spy();
+                $compile(elm)(mock$scope);
+                mock$scope.$digest();
+            };
+        }));
+
+        it('should call the resgistered function on key press event', () => {
+            var elm = angular.element('<input type="text" d2-enter="search(message)"/>');
+            render(elm);
+            var e = jQuery.Event("keydown");
+            e.which = 13; // # Some key code value
+            elm .trigger(e);
+            expect(mock$scope.search).to.be.calledOnce;
+        });
     });
 });
\ No newline at end of file