dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41473
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21131: Restructured the tests.
------------------------------------------------------------
revno: 21131
committer: Jiju K Jose <jijukjose@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-11-19 14:31:51 +0100
message:
Restructured 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 13:06:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/test/directives/d2SetFocus.test.js 2015-11-19 13:31:51 +0000
@@ -1,5 +1,4 @@
const {module, inject} = angular.mock;
-
const {spy} = sinon;
describe('Directives: d2SetFocus', () => {
@@ -7,41 +6,31 @@
let element;
let $timeout;
let render;
-
beforeEach(module('d2Directives'));
- beforeEach(inject(($injector) => {
+ beforeEach(inject(($injector) = > {
const $compile = $injector.get('$compile');
const $rootScope = $injector.get('$rootScope');
-
- render = () => {
- $compile(element)(mock$scope);
- mock$scope.$digest();
- };
-
$timeout = $injector.get('$timeout');
- element = angular.element('<input d2-set-focus="true" />');
- element[0].focus = spy();
-
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 render correctly', () => {
- render();
-
- $timeout.flush();
-
- expect(element[0].focus).to.be.calledOnce;
- });
-
- it('should not set focus when the property is set to false', () => {
- element = angular.element('<input d2-set-focus="false" />');
- element[0].focus = spy();
-
- render();
-
- $timeout.flush();
-
- expect(element[0].focus).to.not.be.called;
- });
-});
+ 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;
+ });
+});
\ No newline at end of file