I'm newbie in testing of Cordova app, so could you please give an advice about what is "best practice" in my situation? Situation: I have a module factory:
angular
.module('app.services')
.factory('UtilsService', UtilsService);
function UtilsService() {
var service = {
isWindows: isWindows,
isAndroid: isAndroid
};
return service;
function isWindows() {
return /windows/i.test(device.platform);
}
function isAndroid() {
return /android/i.test(device.platform);
}
}
and a simple test for isWindows method:
describe('Util Service Tests', function() {
var utilSvc;
beforeEach(function() {
module('app');
});
beforeEach(function () {
inject(function($injector) {
utilSvc = $injector.get('UtilsService');
});
});
it('should detect windows', function () {
expect(utilSvc.isWindows).toBe(true);
});
});
I run tests with Chitzpah runner and get an error:
'device' is undefined
I've found the possible solution like chrome-cordova extension, but it doesn't work in my case (or I'm doing something wrong with it). So what should I do here? Mock calls to device method? If yes, how to do that?
Thanks in advance!