From 181269a2fe25dd9fbb8fb1381857cab613729e91 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sun, 9 Mar 2014 22:01:38 -0500 Subject: [PATCH] do not set a platform if unknown, closes #753 --- .../test/service/ionicPlatform.unit.js | 29 +++++++++++++++++-- js/utils/platform.js | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/js/ext/angular/test/service/ionicPlatform.unit.js b/js/ext/angular/test/service/ionicPlatform.unit.js index 0888b81fb3..93e0d3cf68 100644 --- a/js/ext/angular/test/service/ionicPlatform.unit.js +++ b/js/ext/angular/test/service/ionicPlatform.unit.js @@ -18,13 +18,13 @@ describe('Ionic Platform Service', function() { expect(ionic.Platform.platform()).toEqual('ios'); ionic.Platform.setPlatform(''); - expect(ionic.Platform.platform()).toEqual('unknown'); + expect(ionic.Platform.platform()).toEqual(''); ionic.Platform.setPlatform(null); - expect(ionic.Platform.platform()).toEqual('unknown'); + expect(ionic.Platform.platform()).toEqual(''); ionic.Platform.setPlatform(); - expect(ionic.Platform.platform()).toEqual('unknown'); + expect(ionic.Platform.platform()).toEqual(''); }); it('set version with device', function() { @@ -140,6 +140,29 @@ describe('Ionic Platform Service', function() { expect(ionic.Platform.platforms[3]).toEqual('android4_2'); }); + it('should only set the cordova', function() { + window.cordova = {}; + ionic.Platform.setPlatform(''); + ionic.Platform.setVersion(''); + + ionic.Platform._checkPlatforms() + + expect(ionic.Platform.platforms.length).toEqual(1); + expect(ionic.Platform.platforms[0]).toEqual('cordova'); + }); + + it('should not set any platform', function() { + window.cordova = null; + window.PhoneGap = null; + window.phonegap = null; + ionic.Platform.setPlatform(''); + ionic.Platform.setVersion(''); + + ionic.Platform._checkPlatforms() + + expect(ionic.Platform.platforms.length).toEqual(0); + }); + it('sets grade a from iOS7', function() { window.cordova = {}; ionic.Platform.setPlatform('iOS'); diff --git a/js/utils/platform.js b/js/utils/platform.js index 29102d1c76..f50fdb08d7 100644 --- a/js/utils/platform.js +++ b/js/utils/platform.js @@ -97,7 +97,7 @@ } else if(this.ua.indexOf('iPhone') > -1 || this.ua.indexOf('iPad') > -1 || this.ua.indexOf('iPod') > -1) { platformName = 'ios'; } else { - platformName = 'unknown'; + platformName = ''; } },