Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 0467b2f

Browse files
Hubert KosterHubert Koster
authored andcommitted
chore: refactoring code
1 parent cdacf4a commit 0467b2f

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/features/Endpoint/Endpoint.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface IEndpointFormValues {
1111
}
1212
const EndPoint = () => {
1313
const default_endpoint = {
14-
app_id: getAppId(false),
14+
app_id: getAppId(),
1515
server_url: OAUTH_URL,
1616
};
1717

src/features/Endpoint/__tests__/Endpoint.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Endpoint', () => {
2525
const app_id = screen.getByPlaceholderText('e.g. 9999');
2626
expect(server).toHaveValue('oauth.deriv.com');
2727

28-
expect(app_id).toHaveValue('35073');
28+
expect(app_id).toHaveValue('35074');
2929
});
3030

3131
it('validate user inputs, and provides error messages for app id field', async () => {

src/utils/__tests__/utils.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,23 @@ describe('Get an object with currency data', () => {
3434

3535
describe('Get App ID', () => {
3636
it("Should return 35074 when it's called in localhost environment", () => {
37-
const appId = getAppId(true);
37+
window.location.hostname = 'localhost';
38+
const appId = getAppId();
3839
expect(appId).toBe('35074');
3940
});
4041
it("Should return 35073 when it's called in vercel environment", () => {
4142
window.location.hostname = 'deriv-api-docs.binary.sx';
42-
const appId = getAppId(false);
43+
const appId = getAppId();
4344
expect(appId).toBe('35073');
4445
});
4546
it("Should return 36545 when it's called in staging environment", () => {
4647
window.location.hostname = 'staging-api.deriv.com';
47-
const appId = getAppId(false);
48+
const appId = getAppId();
4849
expect(appId).toBe('36545');
4950
});
5051
it("Should return 36544 when it's called in production environment", () => {
5152
window.location.hostname = 'api.deriv.com';
52-
const appId = getAppId(false);
53+
const appId = getAppId();
5354
expect(appId).toBe('36544');
5455
});
5556
});

src/utils/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ export const isHost = (hostname: string) => {
5959
* @param isLocalHost {boolean} pass `true` if the project is running on localhost
6060
* @returns {string} proper appId for the project
6161
*/
62-
export const getAppId = (isLocalHost: boolean) => {
63-
if (isLocalHost) return LOCALHOST_APP_ID;
64-
62+
export const getAppId = () => {
6563
// if not localhost, then one of the following:
64+
if (isHost('localhost')) return LOCALHOST_APP_ID;
6665
if (isHost('staging-api.deriv.com')) return STAGING_APP_ID;
6766
if (isHost('deriv-api-docs.binary.sx')) return VERCEL_DEPLOYMENT_APP_ID;
6867
if (isHost('api.deriv.com')) return PRODUCTION_APP_ID;
@@ -135,7 +134,7 @@ export const getServerConfig = () => {
135134
const isLocalHost = isHost('localhost');
136135
return {
137136
serverUrl: DEFAULT_WS_SERVER,
138-
appId: getAppId(isLocalHost),
137+
appId: getAppId(),
139138
oauth: OAUTH_URL,
140139
};
141140
}

0 commit comments

Comments
 (0)