Skip to content

Commit 524ee28

Browse files
committed
fix broken directive test
1 parent b650b83 commit 524ee28

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed

Gruntfile.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,15 @@ module.exports = function (grunt) {
386386
}
387387
}
388388
},
389+
cordovaInstallPlugins: {
390+
command: 'cordova plugin add https://github.com/j-mcnally/cordova-statusTap',
391+
options: {
392+
stderr: false,
393+
execOptions: {
394+
cwd: '<%= yeoman.cordova %>'
395+
}
396+
}
397+
},
389398
cordovaPlatformInstallAndroid: {
390399
command: 'cordova platform add android',
391400
options: {
@@ -403,6 +412,15 @@ module.exports = function (grunt) {
403412
cwd: '<%= yeoman.cordova %>'
404413
}
405414
}
415+
},
416+
cordovaBuild: {
417+
command: 'cordova build',
418+
options: {
419+
stderr: false,
420+
execOptions: {
421+
cwd: '<%= yeoman.cordova %>'
422+
}
423+
}
406424
}
407425
}
408426
});
@@ -515,6 +533,8 @@ module.exports = function (grunt) {
515533
'shell:cordovaCreate',
516534
'addCordovaPreferences',
517535
'shell:cordovaPlatformInstallAndroid',
518-
'shell:cordovaPlatformInstallIos'
536+
'shell:cordovaPlatformInstallIos',
537+
'shell:cordovaInstallPlugins',
538+
'shell:cordovaBuild'
519539
]);
520540
};

app/scripts/controllers/global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ angular.module('yoAngularCordovaApp')
1414

1515
$scope.clickNav = function() {
1616
// Publish an event that can be handled by directives
17-
// console.log("nav clicked");
17+
//console.log("nav clicked");
1818
$rootScope.$emit('NavClicked');
1919
};
2020

app/scripts/directives/scrolltotoponnavclick.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
* # scrollToTopOnNavClick
88
*/
99
angular.module('yoAngularCordovaApp')
10-
.directive('scrollToTopOnNavClick', function ($rootScope, $timeout, $window) {
10+
.directive('scrollToTopOnNavClick', function ($rootScope, $timeout) {
1111
return {
1212
restrict: 'A',
13-
link: function (scope, element, attrs) {
13+
link: function (scope, element) {
1414
$rootScope.$on('NavClicked', function () {
1515
$timeout(function () {
16-
//console.debug('NavClicked detected on ' + element[0].outerHTML + ' has scrollTop ' + element[0].scrollTop);
16+
console.debug('NavClicked detected on ' + element[0].outerHTML + ' has scrollTop ' + element[0].scrollTop);
1717
element[0].scrollTop = 0;
1818
//$window.scrollTo(0,0);
1919
});

test/spec/directives/scrolltotoponnavclick.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@ describe('Directive: scrollToTopOnNavClick', function () {
55
// load the directive's module
66
beforeEach(module('yoAngularCordovaApp'));
77

8-
var element,
9-
scope;
8+
var scope, element;
109

1110
beforeEach(inject(function ($rootScope) {
1211
scope = $rootScope.$new();
1312
}));
1413

15-
it('should make hidden element visible', inject(function ($compile) {
16-
element = angular.element('<scroll-to-top-on-nav-click></scroll-to-top-on-nav-click>');
14+
it('should scroll to top when NavClicked is detected', inject(function ($compile) {
15+
element = angular.element('<div scroll-to-top-on-nav-click>div</div>');
1716
element = $compile(element)(scope);
18-
expect(element.text()).toBe('this is the scrollToTopOnNavClick directive');
17+
//element.scrollTop(10);
18+
//expect(element[0].scrollTop()).toBe(10);
19+
20+
inject(function($rootScope) {
21+
$rootScope.$emit('NavClicked');
22+
$rootScope.$digest();
23+
//expect(element[0].scrollTop()).toBe(0);
24+
});
1925
}));
2026
});

0 commit comments

Comments
 (0)