Skip to content

Commit

Permalink
test(platform): iOS from iPod user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jan 9, 2015
1 parent b8112ab commit d24ac30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/utils/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
platformName = getParameterByName('ionicplatform');
} else if (self.ua.indexOf('Android') > 0) {
platformName = ANDROID;
} else if (self.ua.indexOf('iPhone') > -1 || self.ua.indexOf('iPad') > -1 || self.ua.indexOf('iPod') > -1) {
} else if (/iPhone|iPad|iPod/.test(self.ua)) {
platformName = IOS;
} else if (self.ua.indexOf('Windows Phone') > -1) {
platformName = WINDOWS_PHONE;
Expand Down
8 changes: 8 additions & 0 deletions test/unit/angular/service/platform.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ describe('Ionic Platform Service', function() {
expect(ionic.Platform.version()).toEqual(7.0);
});

it('set ios with iPod user agent', function() {
ionic.Platform.ua = 'Mozilla/5.0 (iPod touch; CPU OS 8_1_3 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B511 Safari/9537.53';
ionic.Platform.setPlatform(undefined);
ionic.Platform.setVersion(undefined);
expect(ionic.Platform.platform()).toEqual('ios');
expect(ionic.Platform.version()).toEqual(8.1);
});

it('should not be iPad from none iPad user agent', function() {
ionic.Platform.ua = 'Mozilla/5.0 (iPhone; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53';
ionic.Platform.setPlatform(undefined);
Expand Down

0 comments on commit d24ac30

Please sign in to comment.