Skip to content

Commit 52652d2

Browse files
committed
[AUTOMATED]: Prettier Code Styling
1 parent 8270def commit 52652d2

File tree

4 files changed

+61
-42
lines changed

4 files changed

+61
-42
lines changed

packages-exp/auth-exp/src/core/util/browser.test.ts

+29-16
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,84 @@
1616
*/
1717

1818
import { expect } from 'chai';
19-
import { getBrowserName, BrowserName} from "./browser";
19+
import { getBrowserName, BrowserName } from './browser';
2020

2121
describe('getBrowserName', () => {
2222
it('should recognize Opera', () => {
23-
const userAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36 OPR/36.0.2130.74';
23+
const userAgent =
24+
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36 OPR/36.0.2130.74';
2425
expect(getBrowserName(userAgent)).to.eq(BrowserName.OPERA);
2526
});
26-
27+
2728
it('should recognize IE', () => {
28-
const userAgent = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)';
29+
const userAgent =
30+
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)';
2931
expect(getBrowserName(userAgent)).to.eq(BrowserName.IE);
3032
});
3133

3234
it('should recognize Edge', () => {
33-
const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240';
35+
const userAgent =
36+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240';
3437
expect(getBrowserName(userAgent)).to.eq(BrowserName.EDGE);
3538
});
3639

3740
it('should recognize Firefox', () => {
38-
const userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0';
41+
const userAgent =
42+
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0';
3943
expect(getBrowserName(userAgent)).to.eq(BrowserName.FIREFOX);
4044
});
4145

4246
it('should recognize Silk', () => {
43-
const userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Silk/44.1.54 like Chrome/44.0.2403.63 Safari/537.36';
47+
const userAgent =
48+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Silk/44.1.54 like Chrome/44.0.2403.63 Safari/537.36';
4449
expect(getBrowserName(userAgent)).to.eq(BrowserName.SILK);
4550
});
4651

4752
it('should recognize Safari', () => {
48-
const userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11-4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17';
53+
const userAgent =
54+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11-4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17';
4955
expect(getBrowserName(userAgent)).to.eq(BrowserName.SAFARI);
5056
});
5157

5258
it('should recognize Chrome', () => {
53-
const userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36';
59+
const userAgent =
60+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36';
5461
expect(getBrowserName(userAgent)).to.eq(BrowserName.CHROME);
5562
});
5663

5764
it('should recognize Android', () => {
58-
const userAgent = 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30';
65+
const userAgent =
66+
'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30';
5967
expect(getBrowserName(userAgent)).to.eq(BrowserName.ANDROID);
6068
});
6169

6270
it('should recognize Blackberry', () => {
63-
const userAgent = 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+';
71+
const userAgent =
72+
'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+';
6473
expect(getBrowserName(userAgent)).to.eq(BrowserName.BLACKBERRY);
6574
});
6675

6776
it('should recognize IE Mobile', () => {
68-
const userAgent = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0;Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)';
77+
const userAgent =
78+
'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0;Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)';
6979
expect(getBrowserName(userAgent)).to.eq(BrowserName.IEMOBILE);
7080
});
7181

7282
it('should recognize WebOS', () => {
73-
const userAgent = 'Mozilla/5.0 (webOS/1.3; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Desktop/1.0';
83+
const userAgent =
84+
'Mozilla/5.0 (webOS/1.3; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Desktop/1.0';
7485
expect(getBrowserName(userAgent)).to.eq(BrowserName.WEBOS);
7586
});
7687

7788
it('should recognize an unlisted browser', () => {
78-
const userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Awesome/2.0.012';
89+
const userAgent =
90+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Awesome/2.0.012';
7991
expect(getBrowserName(userAgent)).to.eq('Awesome');
8092
});
8193

8294
it('should default to Other', () => {
83-
const userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 [FBAN/FBIOS;FBAV/27.0.0.10.12;FBBV/8291884;FBDV/iPhone7,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/8.2;FBSS/3; FBCR/vodafoneIE;FBID/phone;FBLC/en_US;FBOP/5]';
95+
const userAgent =
96+
'Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 [FBAN/FBIOS;FBAV/27.0.0.10.12;FBBV/8291884;FBDV/iPhone7,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/8.2;FBSS/3; FBCR/vodafoneIE;FBID/phone;FBLC/en_US;FBOP/5]';
8497
expect(getBrowserName(userAgent)).to.eq(BrowserName.OTHER);
8598
});
86-
});
99+
});

packages-exp/auth-exp/src/core/util/browser.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,31 @@
1919
* Enums for Browser name.
2020
*/
2121
export enum BrowserName {
22-
ANDROID ='Android',
22+
ANDROID = 'Android',
2323
BLACKBERRY = 'Blackberry',
2424
EDGE = 'Edge',
25-
FIREFOX ='Firefox',
25+
FIREFOX = 'Firefox',
2626
IE = 'IE',
27-
IEMOBILE ='IEMobile',
27+
IEMOBILE = 'IEMobile',
2828
OPERA = 'Opera',
2929
OTHER = 'Other',
3030
CHROME = 'Chrome',
3131
SAFARI = 'Safari',
3232
SILK = 'Silk',
3333
WEBOS = 'Webos'
34-
};
34+
}
3535

3636
/**
3737
* Determine the browser for the purposes of reporting usage to the API
3838
*/
3939
export function getBrowserName(userAgent: string): BrowserName | string {
4040
const ua = userAgent.toLowerCase();
41-
if (ua.includes('opera/') ||
42-
ua.includes('opr/') ||
43-
ua.includes('opios/')) {
41+
if (ua.includes('opera/') || ua.includes('opr/') || ua.includes('opios/')) {
4442
return BrowserName.OPERA;
4543
} else if (ua.includes('iemobile')) {
4644
// Windows phone IEMobile browser.
4745
return BrowserName.IEMOBILE;
48-
} else if (ua.includes('msie') ||
49-
ua.includes('trident/')) {
46+
} else if (ua.includes('msie') || ua.includes('trident/')) {
5047
return BrowserName.IE;
5148
} else if (ua.includes('edge/')) {
5249
return BrowserName.EDGE;
@@ -60,25 +57,28 @@ export function getBrowserName(userAgent: string): BrowserName | string {
6057
} else if (ua.includes('webos')) {
6158
// WebOS default browser.
6259
return BrowserName.WEBOS;
63-
} else if (ua.includes('safari/') &&
60+
} else if (
61+
ua.includes('safari/') &&
6462
!ua.includes('chrome/') &&
6563
!ua.includes('crios/') &&
66-
!ua.includes('android')) {
64+
!ua.includes('android')
65+
) {
6766
return BrowserName.SAFARI;
68-
} else if ((ua.includes('chrome/') ||
69-
ua.includes('crios/')) &&
70-
!ua.includes('edge/')) {
67+
} else if (
68+
(ua.includes('chrome/') || ua.includes('crios/')) &&
69+
!ua.includes('edge/')
70+
) {
7171
return BrowserName.CHROME;
7272
} else if (ua.includes('android')) {
7373
// Android stock browser.
7474
return BrowserName.ANDROID;
7575
} else {
7676
// Most modern browsers have name/version at end of user agent string.
77-
const re = new RegExp('([a-zA-Z\\d\\.]+)\/[a-zA-Z\\d\\.]*$');
77+
const re = new RegExp('([a-zA-Z\\d\\.]+)/[a-zA-Z\\d\\.]*$');
7878
const matches = userAgent.match(re);
7979
if (matches && matches.length === 2) {
8080
return matches[1];
8181
}
8282
}
8383
return BrowserName.OTHER;
84-
};
84+
}

packages-exp/auth-exp/src/core/util/version.test.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,25 @@ import { ClientPlatform, getClientVersion } from './version';
2222
describe('getClientVersion', () => {
2323
context('browser', () => {
2424
it('should set the correct version', () => {
25-
expect(getClientVersion(ClientPlatform.BROWSER)).to.eq(`Chrome/JsCore/${firebase.SDK_VERSION}/FirebaseCore-web`);
25+
expect(getClientVersion(ClientPlatform.BROWSER)).to.eq(
26+
`Chrome/JsCore/${firebase.SDK_VERSION}/FirebaseCore-web`
27+
);
2628
});
27-
});
29+
});
2830

2931
context('worker', () => {
3032
it('should set the correct version', () => {
31-
expect(getClientVersion(ClientPlatform.WORKER)).to.eq(`Chrome-Worker/JsCore/${firebase.SDK_VERSION}/FirebaseCore-web`);
33+
expect(getClientVersion(ClientPlatform.WORKER)).to.eq(
34+
`Chrome-Worker/JsCore/${firebase.SDK_VERSION}/FirebaseCore-web`
35+
);
3236
});
33-
});
37+
});
3438

3539
context('React Native', () => {
3640
it('should set the correct version', () => {
37-
expect(getClientVersion(ClientPlatform.REACT_NATIVE)).to.eq(`ReactNative/JsCore/${firebase.SDK_VERSION}/FirebaseCore-web`);
41+
expect(getClientVersion(ClientPlatform.REACT_NATIVE)).to.eq(
42+
`ReactNative/JsCore/${firebase.SDK_VERSION}/FirebaseCore-web`
43+
);
3844
});
39-
});
40-
});
45+
});
46+
});

packages-exp/auth-exp/src/core/util/version.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum ClientFramework {
3434
// Firebase Auth used with FirebaseUI-web.
3535
// TODO: Pass this in when used in conjunction with FirebaseUI
3636
FIREBASEUI = 'FirebaseUI-web'
37-
};
37+
}
3838

3939
/*
4040
* Determine the SDK version string
@@ -43,7 +43,7 @@ enum ClientFramework {
4343
*/
4444
export function getClientVersion(clientPlatform: ClientPlatform): string {
4545
let reportedPlatform: string;
46-
switch(clientPlatform) {
46+
switch (clientPlatform) {
4747
case ClientPlatform.BROWSER:
4848
// In a browser environment, report the browser name.
4949
reportedPlatform = getBrowserName(getUA());
@@ -58,4 +58,4 @@ export function getClientVersion(clientPlatform: ClientPlatform): string {
5858
reportedPlatform = clientPlatform;
5959
}
6060
return `${reportedPlatform}/${CLIENT_IMPLEMENTATION}/${firebase.SDK_VERSION}/${ClientFramework.DEFAULT}`;
61-
}
61+
}

0 commit comments

Comments
 (0)