Skip to content

Commit 2ef08bf

Browse files
committed
Update files with new eslint style
1 parent 700a389 commit 2ef08bf

24 files changed

+185
-152
lines changed

jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ module.exports = {
66
setupFilesAfterEnv: ['./scripts/jest/setup.ts'],
77
modulePathIgnorePatterns: [
88
// https://github.com/facebook/jest/issues/2070#issuecomment-431706685
9-
'<rootDir>/.*/__mocks__'
9+
'<rootDir>/.*/__mocks__',
1010
],
1111
globals: {
12-
__VERSION__: packageJSON.version
13-
}
12+
__VERSION__: packageJSON.version,
13+
},
1414
};

src/__tests__/helper.test.ts

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('helper', () => {
2323
backTo: 'backTo',
2424
authAction: 'signup',
2525
showAuthToggle: true,
26-
showRememberMe: true
26+
showRememberMe: true,
2727
},
2828
{}
2929
)
@@ -32,7 +32,7 @@ describe('helper', () => {
3232
backTo: 'backTo',
3333
authAction: 'signup',
3434
showAuthToggle: true,
35-
showRememberMe: true
35+
showRememberMe: true,
3636
});
3737
});
3838

@@ -44,22 +44,22 @@ describe('helper', () => {
4444
backTo: 'backTo',
4545
authAction: 'signup',
4646
showAuthToggle: true,
47-
showRememberMe: true
47+
showRememberMe: true,
4848
},
4949
{
5050
email: 'newEmail',
5151
backTo: 'newBackTo',
5252
authAction: 'login',
5353
showAuthToggle: false,
54-
showRememberMe: false
54+
showRememberMe: false,
5555
}
5656
)
5757
).toMatchObject({
5858
email: 'newEmail',
5959
backTo: 'newBackTo',
6060
authAction: 'login',
6161
showAuthToggle: false,
62-
showRememberMe: false
62+
showRememberMe: false,
6363
});
6464
});
6565

@@ -72,19 +72,19 @@ describe('helper', () => {
7272
authAction: 'signup',
7373
showAuthToggle: true,
7474
showRememberMe: true,
75-
// @ts-ignore
76-
whatIsThis: false
75+
// @ts-ignore: set unsupported key
76+
whatIsThis: false,
7777
},
7878
{
79-
whatIsThis2: false
79+
whatIsThis2: false,
8080
}
8181
)
8282
).toMatchObject({
8383
email: 'email',
8484
backTo: 'backTo',
8585
authAction: 'signup',
8686
showAuthToggle: true,
87-
showRememberMe: true
87+
showRememberMe: true,
8888
});
8989
});
9090

@@ -96,39 +96,34 @@ describe('helper', () => {
9696
backTo: 'backTo',
9797
authAction: 'signup',
9898
showAuthToggle: true,
99-
showRememberMe: true
99+
showRememberMe: true,
100100
},
101101
{
102102
email: 'newEmail',
103103
backTo: 'newBackTo',
104104
authAction: 'login',
105-
showAuthToggle: false
105+
showAuthToggle: false,
106106
},
107107
['email', 'backTo']
108108
)
109109
).toMatchObject({
110110
authAction: 'login',
111111
showAuthToggle: false,
112-
showRememberMe: true
112+
showRememberMe: true,
113113
});
114114
});
115115
});
116116

117117
describe('generateConfigs', () => {
118118
test('with parameter', () => {
119-
// to test hasOwnProperty not including inherit property
120-
const obj = Object.create({ name: 'inherit' });
121-
122119
expect(
123-
generateConfigs(
124-
Object.assign(obj, {
125-
email: 'email',
126-
backTo: 'backTo',
127-
authAction: 'signup',
128-
showAuthToggle: true,
129-
showRememberMe: true
130-
})
131-
)
120+
generateConfigs({
121+
email: 'email',
122+
backTo: 'backTo',
123+
authAction: 'signup',
124+
showAuthToggle: true,
125+
showRememberMe: true,
126+
})
132127
).toBe(
133128
`sdk_platform=js&sdk_version=${packageJson.version}&email=email&back_to=backTo&auth_action=signup&show_auth_toggle=true` +
134129
`&show_remember_me=true`

src/__tests__/index.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('index', () => {
2222
const instance = new MtLinkSdk();
2323

2424
instance.init('clientId', {
25-
redirectUri: 'redirectUri'
25+
redirectUri: 'redirectUri',
2626
});
2727

2828
const options = instance.storedOptions;
@@ -31,7 +31,7 @@ describe('index', () => {
3131
codeVerifier: options.codeVerifier,
3232
mode: options.mode,
3333
redirectUri: options.redirectUri,
34-
state: options.state
34+
state: options.state,
3535
};
3636

3737
const result1 = instance.authorize({ scopes: 'scopes' });
@@ -59,7 +59,7 @@ describe('index', () => {
5959
expect(result6).toBe('test');
6060
expect(exchangeToken).toBeCalledWith(storedOptions, { code: 'code' });
6161

62-
// @ts-ignore
62+
// @ts-ignore: set tokenInfo with invalid type value
6363
mocked(tokenInfo).mockResolvedValueOnce('test');
6464
const result7 = await instance.tokenInfo('test');
6565
expect(result7).toBe('test');
@@ -82,7 +82,7 @@ describe('index', () => {
8282
mtLinkSdk.init('clientId', {
8383
mode: 'local',
8484
state: 'state',
85-
codeVerifier: 'codeVerifier'
85+
codeVerifier: 'codeVerifier',
8686
});
8787

8888
expect(mtLinkSdk.storedOptions.mode).toBe('local');
@@ -92,8 +92,8 @@ describe('index', () => {
9292

9393
test('invalid mode default to production', () => {
9494
mtLinkSdk.init('clientId', {
95-
// @ts-ignore
96-
mode: 'invalid'
95+
// @ts-ignore: set mode to unsupported value
96+
mode: 'invalid',
9797
});
9898

9999
expect(mtLinkSdk.storedOptions.mode).toBe('production');

src/__tests__/server_paths.test.ts renamed to src/__tests__/server-paths.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { MY_ACCOUNT_DOMAINS, VAULT_DOMAINS, LINK_KIT_DOMAINS } from '../server-p
22

33
describe('server_paths', () => {
44
test('MY_ACCOUNT_DOMAINS', () => {
5-
expect(Object.keys(MY_ACCOUNT_DOMAINS)).toMatchObject(['production', 'staging', 'develop', 'local']);
5+
expect(Object.keys(MY_ACCOUNT_DOMAINS)).toMatchObject([
6+
'production',
7+
'staging',
8+
'develop',
9+
'local',
10+
]);
611

712
expect(MY_ACCOUNT_DOMAINS.production).toContain('myaccount');
813
expect(MY_ACCOUNT_DOMAINS.staging).toContain('myaccount');
@@ -24,7 +29,12 @@ describe('server_paths', () => {
2429
});
2530

2631
test('LINK_KIT_DOMAINS', () => {
27-
expect(Object.keys(LINK_KIT_DOMAINS)).toMatchObject(['production', 'staging', 'develop', 'local']);
32+
expect(Object.keys(LINK_KIT_DOMAINS)).toMatchObject([
33+
'production',
34+
'staging',
35+
'develop',
36+
'local',
37+
]);
2838

2939
expect(LINK_KIT_DOMAINS.production).toContain('linkkit');
3040
expect(LINK_KIT_DOMAINS.staging).toContain('linkkit');

src/api/__tests__/authorize.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('api', () => {
5454
country,
5555
scopes,
5656
locale,
57-
cobrandClientId
57+
cobrandClientId,
5858
});
5959

6060
authorize(mtLinkSdk.storedOptions);
@@ -72,7 +72,7 @@ describe('api', () => {
7272
state,
7373
country,
7474
locale,
75-
configs: generateConfigs()
75+
configs: generateConfigs(),
7676
});
7777
const url = `${MY_ACCOUNT_DOMAINS.production}/oauth/authorize?${query}`;
7878
expect(open).toBeCalledWith(url, '_self');
@@ -99,7 +99,7 @@ describe('api', () => {
9999
codeVerifier,
100100
redirectUri,
101101
country,
102-
scopes
102+
scopes,
103103
});
104104

105105
expect(open).toBeCalledTimes(1);
@@ -113,7 +113,7 @@ describe('api', () => {
113113
code_challenge_method: 'S256',
114114
state,
115115
country,
116-
configs: generateConfigs()
116+
configs: generateConfigs(),
117117
});
118118
const url = `${MY_ACCOUNT_DOMAINS.production}/oauth/authorize?${query}`;
119119
expect(open).toBeCalledWith(url, '_self');
@@ -125,7 +125,7 @@ describe('api', () => {
125125

126126
test('without window', () => {
127127
const windowSpy = jest.spyOn(global, 'window', 'get');
128-
// @ts-ignore
128+
// @ts-ignore: mocking window object to undefined
129129
windowSpy.mockImplementation(() => undefined);
130130

131131
expect(() => {

src/api/__tests__/exchange-token.test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('api', () => {
1515
const mtLinkSdk = new MtLinkSdk();
1616
mtLinkSdk.init(clientId, {
1717
redirectUri,
18-
state
18+
state,
1919
});
2020

2121
test('without calling init', async () => {
@@ -37,7 +37,7 @@ describe('api', () => {
3737
await expect(
3838
exchangeToken(instance.storedOptions, {
3939
code,
40-
state
40+
state,
4141
})
4242
).rejects.toThrow(
4343
'[mt-link-sdk] Missing option `redirectUri` in `exchangeToken`, make sure to pass one via `exchangeToken` options or `init` options.'
@@ -63,14 +63,14 @@ describe('api', () => {
6363
expect(fetch).toBeCalledWith(url, {
6464
method: 'POST',
6565
headers: {
66-
'Content-Type': 'application/json'
66+
'Content-Type': 'application/json',
6767
},
6868
body: JSON.stringify({
6969
code,
7070
client_id: clientId,
7171
grant_type: 'authorization_code',
72-
redirect_uri: redirectUri
73-
})
72+
redirect_uri: redirectUri,
73+
}),
7474
});
7575
});
7676

@@ -80,9 +80,9 @@ describe('api', () => {
8080
fetch.mockClear();
8181
fetch.mockRejectedValueOnce(error);
8282

83-
await expect(exchangeToken(mtLinkSdk.storedOptions, { code, state, redirectUri })).rejects.toThrow(
84-
`[mt-link-sdk] \`exchangeToken\` execution failed. ${error}`
85-
);
83+
await expect(
84+
exchangeToken(mtLinkSdk.storedOptions, { code, state, redirectUri })
85+
).rejects.toThrow(`[mt-link-sdk] \`exchangeToken\` execution failed. ${error}`);
8686
});
8787

8888
test('throw error on response with error', async () => {
@@ -103,7 +103,7 @@ describe('api', () => {
103103
fetch.mockResponseOnce(JSON.stringify({ access_token: token }));
104104

105105
jest.spyOn(window, 'location', 'get').mockReturnValueOnce({
106-
search: `?code=${code1}&code=${code2}`
106+
search: `?code=${code1}&code=${code2}`,
107107
} as typeof window.location);
108108

109109
await exchangeToken(mtLinkSdk.storedOptions, { state });
@@ -122,15 +122,17 @@ describe('api', () => {
122122
fetch.mockResponseOnce(JSON.stringify({ access_token: token }));
123123

124124
jest.spyOn(window, 'location', 'get').mockReturnValueOnce({
125-
search: `?state=${state1}&state=${state}`
125+
search: `?state=${state1}&state=${state}`,
126126
} as typeof window.location);
127127

128-
await expect(exchangeToken(mtLinkSdk.storedOptions, { code, redirectUri })).resolves.toBe(token);
128+
await expect(exchangeToken(mtLinkSdk.storedOptions, { code, redirectUri })).resolves.toBe(
129+
token
130+
);
129131
});
130132

131133
test('non browser environment will not auto extract code from url', async () => {
132134
const windowSpy = jest.spyOn(global, 'window', 'get');
133-
// @ts-ignore
135+
// @ts-ignore: mocking window object to undefined
134136
windowSpy.mockImplementation(() => undefined);
135137

136138
await expect(exchangeToken(mtLinkSdk.storedOptions)).rejects.toThrow(

src/api/__tests__/logout.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('api', () => {
1515
expect(window.open).toBeCalledTimes(1);
1616

1717
const query = qs.stringify({
18-
configs: generateConfigs()
18+
configs: generateConfigs(),
1919
});
2020
const url = `${MY_ACCOUNT_DOMAINS.production}/guests/logout?${query}`;
2121
expect(window.open).toBeCalledWith(url, '_self');
@@ -31,7 +31,7 @@ describe('api', () => {
3131
const mtLinkSkd = new MtLinkSdk();
3232
mtLinkSkd.init(clientId, {
3333
locale,
34-
cobrandClientId
34+
cobrandClientId,
3535
});
3636
logout(mtLinkSkd.storedOptions);
3737

@@ -41,7 +41,7 @@ describe('api', () => {
4141
client_id: clientId,
4242
cobrand_client_id: cobrandClientId,
4343
locale,
44-
configs: generateConfigs()
44+
configs: generateConfigs(),
4545
});
4646
const url = `${MY_ACCOUNT_DOMAINS.production}/guests/logout?${query}`;
4747
expect(window.open).toBeCalledWith(url, '_self');
@@ -53,23 +53,23 @@ describe('api', () => {
5353
const backTo = 'backTo';
5454

5555
logout(new MtLinkSdk().storedOptions, {
56-
backTo
56+
backTo,
5757
});
5858

5959
expect(window.open).toBeCalledTimes(1);
6060

6161
const query = qs.stringify({
6262
configs: generateConfigs({
63-
backTo
64-
})
63+
backTo,
64+
}),
6565
});
6666
const url = `${MY_ACCOUNT_DOMAINS.production}/guests/logout?${query}`;
6767
expect(window.open).toBeCalledWith(url, '_self');
6868
});
6969

7070
test('without window', () => {
7171
const windowSpy = jest.spyOn(global, 'window', 'get');
72-
// @ts-ignore
72+
// @ts-ignore: mocking window object to undefined
7373
windowSpy.mockImplementation(() => undefined);
7474

7575
expect(() => {

0 commit comments

Comments
 (0)