mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
do not set a platform if unknown, closes #753
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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 = '';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user