do not set a platform if unknown, closes #753

This commit is contained in:
Adam Bradley
2014-03-09 22:01:38 -05:00
parent 1f4b59a9eb
commit 181269a2fe
2 changed files with 27 additions and 4 deletions

View File

@@ -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');

View File

@@ -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 = '';
}
},