← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21147: Ädded test for d2CustomForm directive

 

------------------------------------------------------------
revno: 21147
committer: Jiju K Jose <jijukjose@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-11-20 16:57:37 +0100
message:
  Ädded test for d2CustomForm directive
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-20 13:54:22 +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 15:57:37 +0000
@@ -48,7 +48,7 @@
         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() {
 
@@ -103,4 +103,74 @@
             expect(mySpy).to.have.been.calledOnce;
         });
     });
+
+    /*TODO: Test not added for d2Sortable*/
+
+    describe('Directive: serversidePaginator', () => {
+        let mock$scope;
+        let element;
+        let render;
+        beforeEach(inject(($injector) => {
+        const $compile = $injector.get('$compile');
+            const $rootScope = $injector.get('$rootScope');
+            $timeout = $injector.get('$timeout');
+            mock$scope = $rootScope.$new();
+
+            render = (elm) =>
+            {
+                $compile(elm)(mock$scope);
+                mock$scope.$digest();
+            };
+        }));
+        /* TODO ../dhis-web-commons/angular-forms/serverside-pagination.html is not loaded. */
+        /* works if the path in specified as ../../../dhis-web-commons/angular-forms/serverside-pagination.html */
+        xit('should set the focus when the attribute property is set to true', () => {
+            var elm = '<serverside-paginator></serverside-paginator>';
+            render(elm);
+            expect(mock$scope.paginator).to.be.defined();
+        });
+    });
+
+    /*TODO: draggabkModal directive is not used and likely to be removed*/
+    xdescribe('Directive: draggableModal', () => {
+        let mock$scope;
+        let render;
+        let mySpy;
+        beforeEach(inject(($injector) => {
+            const $compile = $injector.get('$compile');
+            const $rootScope = $injector.get('$rootScope');
+            mock$scope = $rootScope.$new();
+            render = (elm) =>
+            {
+                elm.draggable = function() {};
+                mySpy = spy(elm, "draggable");
+                $compile(elm)(mock$scope);
+                mock$scope.$digest();
+            };
+        }));
+        /* TODO ../dhis-web-commons/angular-forms/serverside-pagination.html is not loaded. */
+        /* works if the path in specified as ../../../dhis-web-commons/angular-forms/serverside-pagination.html */
+        it('call the draggable function when loaded.', () => {
+            var elm = angular.element('<draggable-modal></draggable-modal>');
+            render(elm);
+            expect(mySpy).to.have.been.calledOnce;
+        });
+    });
+
+    describe('Directive: d2CustomForm', () => {
+        let mock$scope;
+        let render;
+        let $compile;
+        beforeEach(inject(($injector) => {
+            $compile = $injector.get('$compile');
+            mock$scope = $injector.get('$rootScope').$new();
+        }));
+        it('should watch and process the customForm scope variable', () => {
+            let elm = angular.element('<d2-custom-form></d2-custom-form>');
+            $compile(elm)(mock$scope);
+            mock$scope.customForm= {htmlCode:'<div>TestContentOne</div>'};
+            mock$scope.$digest();
+            expect(elm[0].innerHTML).to.equal('<div class="ng-scope">TestContentOne</div>');
+        });
+    });
 });
\ No newline at end of file