Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(platform): new user agent tests #10215

Merged
merged 3 commits into from
Jan 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/platform/test/platform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ describe('Platform', () => {
expect(plt.is('windows')).toEqual(false);
expect(plt.is('android')).toEqual(true);
expect(plt.is('ios')).toEqual(false);

plt.setQueryParams('');
plt.setUserAgent(ANDROID_7_1_1_UA);
plt.init();

expect(plt.is('core')).toEqual(false);
expect(plt.is('mobile')).toEqual(true);
expect(plt.is('windows')).toEqual(false);
expect(plt.is('android')).toEqual(true);
expect(plt.is('ios')).toEqual(false);
});

it('should set iphone via user agent', () => {
Expand All @@ -308,6 +318,20 @@ describe('Platform', () => {
expect(plt.is('android')).toEqual(false);
expect(plt.is('ios')).toEqual(true);
expect(plt.is('iphone')).toEqual(true);
expect(plt.is('ipad')).toEqual(false);
expect(plt.is('tablet')).toEqual(false);

plt.setQueryParams('');
plt.setUserAgent(IPHONE_10_2_UA);
plt.init();

expect(plt.is('core')).toEqual(false);
expect(plt.is('mobile')).toEqual(true);
expect(plt.is('windows')).toEqual(false);
expect(plt.is('android')).toEqual(false);
expect(plt.is('ios')).toEqual(true);
expect(plt.is('iphone')).toEqual(true);
expect(plt.is('ipad')).toEqual(false);
expect(plt.is('tablet')).toEqual(false);
});

Expand All @@ -322,6 +346,20 @@ describe('Platform', () => {
expect(plt.is('android')).toEqual(false);
expect(plt.is('ios')).toEqual(true);
expect(plt.is('ipad')).toEqual(true);
expect(plt.is('iphone')).toEqual(false);
expect(plt.is('tablet')).toEqual(true);

plt.setQueryParams('');
plt.setUserAgent(IPAD_10_2_UA);
plt.init();

expect(plt.is('core')).toEqual(false);
expect(plt.is('mobile')).toEqual(true);
expect(plt.is('windows')).toEqual(false);
expect(plt.is('android')).toEqual(false);
expect(plt.is('ios')).toEqual(true);
expect(plt.is('ipad')).toEqual(true);
expect(plt.is('iphone')).toEqual(false);
expect(plt.is('tablet')).toEqual(true);
});

Expand Down Expand Up @@ -440,5 +478,9 @@ const WINDOWS8_PHONE_UA = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0
const WINDOWS7_PHONE_UA = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)';

const ANDROID_UA = 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.20 Mobile Safari/537.36';
const ANDROID_7_1_1_UA = 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36';

const IPHONE_UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4';
const IPHONE_10_2_UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Mobile/14C89 (140564782665216)';
const IPAD_UA = 'Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53';
const IPAD_10_2_UA = 'Mozilla/5.0 (iPad; CPU OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Mobile/14C89 (140342232906320)';