Skip to content

Commit

Permalink
feat: changed client code to dynamically perform calls to the domain …
Browse files Browse the repository at this point in the history
…in the browser address bar
  • Loading branch information
Ranguna committed Oct 9, 2022
1 parent 9126c89 commit 51f03f2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
15 changes: 0 additions & 15 deletions app/client/src/api/config.ts

This file was deleted.

15 changes: 1 addition & 14 deletions app/client/src/api/generator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import generator from './generator';
import { TEST_PORT, TEST_HOST, TEST_PROTOCOL } from './mocks/generatorTestVariables';

// how to use local variables in jest mock to get rid of hoisting mocks to top most code block:
//stackoverflow.com/questions/44649699/service-mocked-with-jest-causes-the-module-factory-of-jest-mock-is-not-allowe
jest.mock('./config', () => {
const generatorTestVariables = require('./mocks/generatorTestVariables');

return {
host: generatorTestVariables.TEST_HOST,
protocol: generatorTestVariables.TEST_PROTOCOL,
port: generatorTestVariables.TEST_PORT,
};
});


describe('generator.ts', () => {
afterEach(() => {
jest.clearAllMocks();
Expand All @@ -27,7 +14,7 @@ describe('generator.ts', () => {
const result = generator(roomID);

expect(result).toMatch(
`${TEST_PROTOCOL}://${TEST_HOST}:${TEST_PORT}/${roomID}`
`/${roomID}`
);
});
});
Expand Down
9 changes: 1 addition & 8 deletions app/client/src/api/generator.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import config from './config';

export default (resourceName = '') => {
const { port, protocol, host } = config;

const resourcePath = resourceName;

if (!host) {
return `/localhost`;
}

return `${protocol}://${host}:${port}/${resourcePath}`;
return `/${resourcePath}`;
};
1 change: 1 addition & 0 deletions app/components/StepsOfStepper/ScanQRStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IpcEvents } from '../../main/IpcEvents.enum';

const { port } = config;

// can the comment bellow be removed? Because the port is being defined in the config file, although it can't be changed after bundling I think
// TODO: change port to user defined port, if it is really defined
const CLIENT_VIEWER_PORT = isProduction() ? port : '3000';

Expand Down

0 comments on commit 51f03f2

Please sign in to comment.