Skip to content

Commit

Permalink
chore(travis): make tests work with phantomjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed May 21, 2014
1 parent 57c79a3 commit 93e0191
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 32 deletions.
16 changes: 9 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,15 @@ gulp.task('cloudtest', ['protractor-sauce'], function(cb) {
});

gulp.task('karma', function(cb) {
return karma.start(_.assign(require('./config/karma.conf.js'), {singleRun: true}), cb);
var config = require('./config/karma.conf.js');
config.singleRun = true;
if (argv.browsers) {
config.browsers = argv.browsers.trim().split(',');
}
if (argv.reporters) {
config.reporters = argv.reporters.trim().split(',');
}
return karma.start(config, cb);
});
gulp.task('karma-watch', function(cb) {
return karma.start(_.assign(require('./config/karma.conf.js'), {singleRun: false}), cb);
Expand All @@ -401,12 +409,6 @@ gulp.task('protractor-sauce', ['sauce-connect', 'connect-server'], function(cb)
});

function karma(cb, args) {
if (argv.browsers) {
args.push('--browsers='+argv.browsers.trim());
}
if (argv.reporters) {
args.push('--reporters='+argv.reporters.trim());
}
cp.spawn('node', [
__dirname + '/node_modules/karma/bin/karma',
'start'
Expand Down
27 changes: 14 additions & 13 deletions js/angular/directive/keyboardAttach.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*
* @description
* keyboard-attach is an attribute directive which will cause an element to float above
* the keyboard when the keyboard shows. Currently only supports the
* the keyboard when the keyboard shows. Currently only supports the
* [ion-footer-bar]({{ page.versionHref }}/api/directive/ionFooterBar/) directive.
*
* ### Notes
* - This directive requires the
*
* ### Notes
* - This directive requires the
* [Ionic Keyboard Plugin](https://github.com/driftyco/ionic-plugins-keyboard).
* - On Android not in fullscreen mode, i.e. you have
* `<preference name="Fullscreen" value="true" />` in your `config.xml` file,
Expand All @@ -30,12 +30,12 @@
IonicModule
.directive('keyboardAttach', function() {
return function(scope, element, attrs) {
window.addEventListener('native.keyboardshow', onShow);
window.addEventListener('native.keyboardhide', onHide);
ionic.on('native.keyboardshow', onShow, window);
ionic.on('native.keyboardhide', onHide, window);

//deprecated
window.addEventListener('native.showkeyboard', onShow);
window.addEventListener('native.hidekeyboard', onHide);
ionic.on('native.showkeyboard', onShow, window);
ionic.on('native.hidekeyboard', onHide, window);


var scrollCtrl;
Expand Down Expand Up @@ -66,11 +66,12 @@ IonicModule
}

scope.$on('$destroy', function() {
window.removeEventListener('native.keyboardshow', onShow);
window.removeEventListener('native.keyboardhide', onHide);

window.removeEventListener('native.showkeyboard', onShow);
window.removeEventListener('native.hidekeyboard', onHide);
ionic.off('native.keyboardshow', onShow, window);
ionic.off('native.keyboardhide', onHide, window);

//deprecated
ionic.off('native.showkeyboard', onShow, window);
ionic.off('native.hidekeyboard', onHide, window);
});
};
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ionic",
"private": false,
"version": "1.0.0-beta.5b",
"version": "1.0.0-beta.5b-nightly-22740",
"codename": "cadmium-camel",
"repository": {
"url": "git://github.com/driftyco/ionic.git"
Expand Down
14 changes: 3 additions & 11 deletions test/unit/angular/directive/keyboardAttach.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,10 @@ describe('keyboardAttach directive', function() {
});

it('should remove listeners on destroy', function() {
spyOn(window, 'removeEventListener');
spyOn(ionic, 'off');
var el = setup().el;
el.scope().$destroy();
expect(window.removeEventListener).toHaveBeenCalledWith('native.showkeyboard', jasmine.any(Function));
expect(window.removeEventListener).toHaveBeenCalledWith('native.hidekeyboard', jasmine.any(Function));
});

it('should remove listeners on destroy', function() {
spyOn(window, 'removeEventListener');
var el = setup().el;
el.scope().$destroy();
expect(window.removeEventListener).toHaveBeenCalledWith('native.showkeyboard', jasmine.any(Function));
expect(window.removeEventListener).toHaveBeenCalledWith('native.hidekeyboard', jasmine.any(Function));
expect(ionic.off).toHaveBeenCalledWith('native.keyboardshow', jasmine.any(Function), window);
expect(ionic.off).toHaveBeenCalledWith('native.keyboardhide', jasmine.any(Function), window);
});
})

0 comments on commit 93e0191

Please sign in to comment.