Permalink
Browse files

Fix tests by upgrade karma and jasmine

Updated packages:
karma, karma-chrome-launcher, karma-coverage, karma-jasmine,
karma-phantomjs-launcher

New (necessary) packages:
jasmine-core, phantomjs-prebuilt

Updated Jasmine commands (Jasmine 1.3 -> Jasmine 2):

spyOn(window.push, 'register').andCallFake ->
spyOn(window.push, 'register').and.callFake

expect(window.push.unregister.calls[0].args[2]).toBe(config) ->
expect(window.push.unregister.calls.argsFor(0)[2]).toBe(config)

spyOn($rootScope, '$broadcast').andCallThrough() ->
spyOn($rootScope, '$broadcast').and.callThrough()
  • Loading branch information...
1 parent ce58c66 commit 9af3ab6f55440210a1544a69889adfabd335419e @pbakondy pbakondy committed Feb 25, 2016
@@ -20,6 +20,13 @@ module.exports = {
'src/plugins/*.js': ['coverage']
},
+ plugins: [
+ 'karma-jasmine',
+ 'karma-phantomjs-launcher',
+ 'karma-chrome-launcher',
+ 'karma-coverage'
+ ],
+
coverageReporter: {
type : 'html',
dir : 'coverage/'
@@ -43,4 +50,3 @@ module.exports = {
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['Chrome']
};
-
View
@@ -6,7 +6,7 @@ var gulp = require('gulp'),
header = require('gulp-header'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
- karma = require('karma').server,
+ Server = require('karma').Server,
karmaConf = require('./config/karma.conf.js'),
rename = require('gulp-rename'),
shell = require('gulp-shell'),
@@ -75,7 +75,8 @@ gulp.task('karma', function (done) {
karmaConf.singleRun = true;
argv.browsers && (karmaConf.browsers = argv.browsers.trim().split(','));
argv.reporters && (karmaConf.reporters = argv.reporters.trim().split(','));
- karma.start(karmaConf, done);
+ var server = new Server(karmaConf, done);
+ server.start();
});
gulp.task('jshint', function () {
@@ -105,7 +106,8 @@ gulp.task('jscs', function () {
gulp.task('karma-watch', function (done) {
console.log(karmaConf);
karmaConf.singleRun = false;
- karma.start(karmaConf, done);
+ var server = new Server(karmaConf, done);
+ server.start();
});
gulp.task('watch', ['build'], function () {
View
@@ -17,13 +17,15 @@
"gulp-rename": "^1.2.0",
"gulp-shell": "^0.2.10",
"gulp-uglify": "^0.2.1",
+ "jasmine-core": "^2.4.1",
"jshint-stylish": "^0.4.0",
- "karma": "^0.12.16",
- "karma-chrome-launcher": "~0.1.2",
- "karma-coverage": "~0.2.6",
- "karma-jasmine": "~0.1.5",
- "karma-phantomjs-launcher": "~0.1.2",
- "minimist": "^0.1.0"
+ "karma": "^0.13.21",
+ "karma-chrome-launcher": "~0.2.2",
+ "karma-coverage": "~0.5.3",
+ "karma-jasmine": "~0.3.7",
+ "karma-phantomjs-launcher": "~1.0.0",
+ "minimist": "^0.1.0",
+ "phantomjs-prebuilt": "^2.1.4"
},
"licenses": [
{
@@ -33,7 +33,7 @@ describe('Service: $cordovaAdMob', function() {
var options = { someOption: 1 };
spyOn(window.plugins.AdMob, fnName)
- .andCallFake(function (options, successCb, errorCb) {
+ .and.callFake(function (options, successCb, errorCb) {
successCb();
});
@@ -53,7 +53,7 @@ describe('Service: $cordovaAdMob', function() {
var options = { someOption: 1 };
spyOn(window.plugins.AdMob, fnName)
- .andCallFake(function (options, successCb, errorCb) {
+ .and.callFake(function (options, successCb, errorCb) {
errorCb();
});
@@ -18,7 +18,7 @@ describe('Service: $cordovaAppAvailability', function() {
var result;
spyOn(window.appAvailability, 'check')
- .andCallFake(function (urlScheme, successCb, errorCb) {
+ .and.callFake(function (urlScheme, successCb, errorCb) {
successCb(true);
});
@@ -31,7 +31,7 @@ describe('Service: $cordovaAppAvailability', function() {
$rootScope.$digest();
expect(result).toBe(true);
- expect(window.appAvailability.check.calls[0].args[0]).toBe('twitter://');
+ expect(window.appAvailability.check.calls.argsFor(0)[0]).toBe('twitter://');
});
it('should call errorCb when in window\'s appAvailability.check a error orccurs', function() {
@@ -40,7 +40,7 @@ describe('Service: $cordovaAppAvailability', function() {
var errorObj = { someError: 1 };
spyOn(window.appAvailability, 'check')
- .andCallFake(function (urlScheme, successCb, errorCb) {
+ .and.callFake(function (urlScheme, successCb, errorCb) {
errorCb(errorObj);
});
@@ -27,7 +27,7 @@ describe('Service: $cordovaBarcodeScanner', function () {
var imageData = {data: '123456789'};
spyOn(cordova.plugins.barcodeScanner, 'scan')
- .andCallFake(function (successCb, errorCb) {
+ .and.callFake(function (successCb, errorCb) {
successCb(imageData);
});
@@ -15,7 +15,7 @@ describe('Service: $cordovaBatteryStatus', function () {
(function (eventName) {
it('should broadcast the `' + eventName + '` event the right way', function () {
- spyOn($rootScope, '$broadcast').andCallThrough();
+ spyOn($rootScope, '$broadcast').and.callThrough();
var result = {'isPlugged': true, 'level': 1};
@@ -37,7 +37,7 @@ describe('Service: $cordovaCamera', function() {
var imageData = { url: 'file://blob' };
spyOn(navigator.camera, 'getPicture')
- .andCallFake(function (successCb, errorCb, options) {
+ .and.callFake(function (successCb, errorCb, options) {
successCb(imageData);
});
@@ -50,7 +50,7 @@ describe('Service: $cordovaCamera', function() {
$rootScope.$digest();
expect(result).toBe(imageData);
- expect(navigator.camera.getPicture.calls[0].args[2]).toBe(options);
+ expect(navigator.camera.getPicture.calls.argsFor(0)[2]).toBe(options);
});
it('should call errorCb when in window\'s appAvailability.getPicture a error orccurs', function() {
@@ -59,7 +59,7 @@ describe('Service: $cordovaCamera', function() {
var errorObj = { someError: 1 };
spyOn(navigator.camera, 'getPicture')
- .andCallFake(function (successCb, errorCb, options) {
+ .and.callFake(function (successCb, errorCb, options) {
errorCb(errorObj);
});
@@ -79,15 +79,15 @@ describe('Service: $cordovaCamera', function() {
var options = { someOptions: 1 };
spyOn(navigator.camera, 'cleanup')
- .andCallFake(function (successCb, errorCb) {
+ .and.callFake(function (successCb, errorCb) {
successCb();
});
$cordovaCamera.cleanup();
$rootScope.$digest();
- expect(navigator.camera.cleanup.calls[0].args[2]).toBe();
+ expect(navigator.camera.cleanup.calls.argsFor(0)[2]).toBe();
});
it('should call errorCb when in window\'s appAvailability.cleanup a error orccurs', function() {
@@ -96,7 +96,7 @@ describe('Service: $cordovaCamera', function() {
var errorObj = { someError: 1 };
spyOn(navigator.camera, 'cleanup')
- .andCallFake(function (successCb, errorCb, options) {
+ .and.callFake(function (successCb, errorCb, options) {
errorCb(errorObj);
});
@@ -32,7 +32,7 @@ describe('Service: $cordovaCapture', function() {
var options = { someOption: 1 };
spyOn(navigator.device.capture, fnName)
- .andCallFake(function (successCb, errorCb, options) {
+ .and.callFake(function (successCb, errorCb, options) {
successCb(true);
});
@@ -44,7 +44,7 @@ describe('Service: $cordovaCapture', function() {
$rootScope.$digest();
expect(result).toBe(true);
- expect(navigator.device.capture[fnName].calls[0].args[2]).toBe(options);
+ expect(navigator.device.capture[fnName].calls.argsFor(0)[2]).toBe(options);
});
it('navigator\'s device.capture.' + fnName + ' return `null` when device.capture is not set', function() {
@@ -70,7 +70,7 @@ describe('Service: $cordovaCapture', function() {
var errorObj = { someError: 1 };
spyOn(navigator.device.capture, fnName)
- .andCallFake(function (successCb, errorCb, options) {
+ .and.callFake(function (successCb, errorCb, options) {
errorCb(errorObj);
});
@@ -19,7 +19,7 @@ describe('Service: $cordovaDatePicker', function() {
var options = { mode: 'date', date: new Date() };
spyOn(window.datePicker, 'show')
- .andCallFake(function (options, successCb, errorCb) {
+ .and.callFake(function (options, successCb, errorCb) {
successCb(options.date);
});
@@ -32,14 +32,14 @@ describe('Service: $cordovaDatePicker', function() {
$rootScope.$digest();
expect(result).toBe(options.date);
- expect(window.datePicker.show.calls[0].args[0]).toBe(options);
+ expect(window.datePicker.show.calls.argsFor(0)[0]).toBe(options);
});
it('should have default options if none are passed', function() {
var result;
spyOn(window.datePicker, 'show')
- .andCallFake(function(options, successCb, errorCb) {
+ .and.callFake(function(options, successCb, errorCb) {
successCb(options.date);
});
@@ -26,7 +26,7 @@ describe('Service: $cordovaDialogs', function () {
var buttonName = "Okay";
spyOn(navigator.notification, 'alert')
- .andCallFake(function (message, successCb, title, buttonName) {
+ .and.callFake(function (message, successCb, title, buttonName) {
successCb();
});
@@ -28,7 +28,7 @@ describe('Service: $cordovaFlashlight', function() {
it('should call window\'s plugins.flashlight.available method', function() {
spyOn(window.plugins.flashlight, 'available')
- .andCallFake(function (successCb, errorCb) {
+ .and.callFake(function (successCb, errorCb) {
successCb();
});
@@ -44,7 +44,7 @@ describe('Service: $cordovaFlashlight', function() {
it('should call window\'s plugins.flashlight.' + fnName + ' method', function() {
spyOn(window.plugins.flashlight, fnName)
- .andCallFake(function (successCb, errorCb) {
+ .and.callFake(function (successCb, errorCb) {
successCb();
});
@@ -63,7 +63,7 @@ describe('Service: $cordovaFlashlight', function() {
var errorObj = { someError: 1 };
spyOn(window.plugins.flashlight, fnName)
- .andCallFake(function (successCb, errorCb) {
+ .and.callFake(function (successCb, errorCb) {
errorCb(errorObj);
});
Oops, something went wrong.

0 comments on commit 9af3ab6

Please sign in to comment.