Skip to content

Commit

Permalink
[INJIWEB-977]: Fixed Comments in Util
Browse files Browse the repository at this point in the history
Signed-off-by: Kamlesh Singh Bisht <[email protected]>
  • Loading branch information
kamlesh012 committed Oct 21, 2024
1 parent 083b325 commit 05557e4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 35 deletions.
3 changes: 1 addition & 2 deletions inji-web/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
CI=false
BASE_URL="http://localhost:3010"
CI=false
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports[`Testing the Layout of LandingPageWrapper Check if the layout is matchin
class="text-iw-primary font-bold py-2 px-4 rounded-lg border-2 border-iw-primary"
data-testid="DownloadResult-Home-Button"
>
Go To Home
navigateButton
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ exports[`Testing the Layout of NavBar Check the presence of the navbar container
<input
class="py-6 w-11/12 flex text-iw-searchTitle focus:outline-none overflow-ellipsis mr-10"
data-testid="NavBar-Search-Input"
placeholder="Search Credential Type"
placeholder="searchText"
type="text"
value=""
/>
Expand Down
20 changes: 10 additions & 10 deletions inji-web/src/__tests__/utils/api.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('api class', () => {

Object.defineProperty(window, 'location', {
value: {
origin: 'http://localhost:3010'
origin: 'https://api.collab.mossip.net'
},
writable: true
});
Expand All @@ -31,16 +31,16 @@ describe('api class', () => {
});

test('should have the correct mimotoHost', () => {
expect(apiModule.api.mimotoHost).toBe('http://localhost:3010/v1/mimoto');
expect(apiModule.api.mimotoHost).toBe('https://api.collab.mossip.net/v1/mimoto');
});

test('should have the correct authorizationRedirectionUrl', () => {
expect(apiModule.api.authorizationRedirectionUrl).toBe('http://localhost:3010/redirect');
expect(apiModule.api.authorizationRedirectionUrl).toBe('https://api.collab.mossip.net/redirect');
});

test('should have the correct fetchIssuers request', () => {
const fetchIssuers: ApiRequest = apiModule.api.fetchIssuers;
expect(fetchIssuers.url()).toBe('http://localhost:3010/v1/mimoto/issuers');
expect(fetchIssuers.url()).toBe('https://api.collab.mossip.net/v1/mimoto/issuers');
expect(fetchIssuers.methodType).toBe(apiModule.MethodType.GET);
expect(fetchIssuers.headers()).toEqual({
'Content-Type': 'application/json'
Expand All @@ -50,7 +50,7 @@ describe('api class', () => {
test('should have the correct fetchSpecificIssuer request', () => {
const issuerId = '123';
const fetchSpecificIssuer: ApiRequest = apiModule.api.fetchSpecificIssuer;
expect(fetchSpecificIssuer.url(issuerId)).toBe('http://localhost:3010/v1/mimoto/issuers/123');
expect(fetchSpecificIssuer.url(issuerId)).toBe('https://api.collab.mossip.net/v1/mimoto/issuers/123');
expect(fetchSpecificIssuer.methodType).toBe(apiModule.MethodType.GET);
expect(fetchSpecificIssuer.headers()).toEqual({
'Content-Type': 'application/json'
Expand All @@ -60,7 +60,7 @@ describe('api class', () => {
test('should have the correct fetchIssuersWellknown request', () => {
const issuerId = '123';
const fetchIssuersWellknown: ApiRequest = apiModule.api.fetchIssuersWellknown;
expect(fetchIssuersWellknown.url(issuerId)).toBe('http://localhost:3010/v1/mimoto/issuers/123/well-known-proxy');
expect(fetchIssuersWellknown.url(issuerId)).toBe('https://api.collab.mossip.net/v1/mimoto/issuers/123/well-known-proxy');
expect(fetchIssuersWellknown.methodType).toBe(apiModule.MethodType.GET);
expect(fetchIssuersWellknown.headers()).toEqual({
'Content-Type': 'application/json'
Expand All @@ -69,7 +69,7 @@ describe('api class', () => {

test('should have the correct fetchTokenAnddownloadVc request', () => {
const fetchTokenAnddownloadVc: ApiRequest = apiModule.api.fetchTokenAnddownloadVc;
expect(fetchTokenAnddownloadVc.url()).toBe('http://localhost:3010/v1/mimoto/credentials/download');
expect(fetchTokenAnddownloadVc.url()).toBe('https://api.collab.mossip.net/v1/mimoto/credentials/download');
expect(fetchTokenAnddownloadVc.methodType).toBe(apiModule.MethodType.POST);
expect(fetchTokenAnddownloadVc.headers()).toEqual({
'accept': 'application/json',
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('api class', () => {
}
],
client_id: 'client123',
redirect_uri: 'http://localhost:3010/redirect',
redirect_uri: 'https://api.collab.mossip.net/redirect',
token_endpoint: 'http://token.endpoint',
proxy_token_endpoint: 'http://proxy.token.endpoint',
client_alias: 'clientAlias',
Expand Down Expand Up @@ -158,11 +158,11 @@ describe('api class', () => {
'?response_type=code&' +
'client_id=client123&' +
'scope=openid&' +
`redirect_uri=http://localhost:3010/redirect&` +
`redirect_uri=https://api.collab.mossip.net/redirect&` +
'state=state123&' +
'code_challenge=challenge123&' +
'code_challenge_method=S256&' +
'ui_locales=' + i18n.language
);
});
});
});
17 changes: 8 additions & 9 deletions inji-web/src/__tests__/utils/i18n.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { initReactI18next } from 'react-i18next';
import { setReduxState, clearReduxState } from '../../test-utils/reduxMockUtils';
import en from '../../locales/en.json';
Expand Down Expand Up @@ -77,7 +76,7 @@ describe('i18n configuration', () => {
});

describe('initialization', () => {
it('should initialize with selected language', async () => {
test('should initialize with selected language', async () => {
const selectedLanguage = 'ar';
mockStorage.getItem.mockReturnValue(selectedLanguage);

Expand All @@ -97,7 +96,7 @@ describe('i18n configuration', () => {
}));
});

it('should initialize with default language when none selected', async () => {
test('should initialize with default language when none selected', async () => {
mockStorage.getItem.mockReturnValue(null);

await i18nModule.initializeI18n();
Expand All @@ -113,20 +112,20 @@ describe('i18n configuration', () => {
});

describe('language direction', () => {
it('should correctly identify RTL languages', () => {
test('should correctly identify RTL languages', () => {
expect(i18nModule.isRTL('ar')).toBe(true);
expect(i18nModule.isRTL('en')).toBe(false);
expect(i18nModule.isRTL('fr')).toBe(false);
});

it('should return correct direction for language', () => {
test('should return correct direction for language', () => {
expect(i18nModule.getDirCurrentLanguage('ar')).toBe('rtl');
expect(i18nModule.getDirCurrentLanguage('en')).toBe('ltr');
});
});

describe('switching language', () => {
it('should store and change language', async () => {
test('should store and change language', async () => {
const newLanguage = 'fr';
await i18nModule.switchLanguage(newLanguage);

Expand All @@ -136,7 +135,7 @@ describe('i18n configuration', () => {
});

describe('getObjectForCurrentLanguage', () => {
it('should return object for current language', () => {
test('should return object for current language', () => {
const displayArray = [
{ language: 'en', value: 'English' },
{ language: 'fr', value: 'French' }
Expand All @@ -146,7 +145,7 @@ describe('i18n configuration', () => {
expect(result).toEqual({ language: 'fr', value: 'French' });
});

it('should fall back to default language if requested language not found', () => {
test('should fall back to default language if requested language not found', () => {
const displayArray = [
{ language: 'en', value: 'English' },
{ language: 'fr', value: 'French' }
Expand All @@ -156,4 +155,4 @@ describe('i18n configuration', () => {
expect(result).toEqual({ language: 'en', value: 'English' });
});
});
});
});
15 changes: 4 additions & 11 deletions inji-web/src/test-utils/mockUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,22 @@ export const wrapUnderRouter = (children: React.ReactNode) => {
return <Router>{children}</Router>;
};

export const mockUseToast = () => {
jest.mock('react-toastify', () => ({
toast: jest.fn(),
ToastContainer: jest.requireActual('react-toastify').ToastContainer,
}));
};

// Component Mocks
export const mockUseSearchCredentials = () => {
jest.mock('../components/Credentials/SearchCredential', () => ({
SearchCredential: () => <div data-testid="mock-search-credential" />
SearchCredential: () => <></>,
}));
};

export const mockUseSpinningLoader = () => {
jest.mock('../components/Common/SpinningLoader', () => ({
SpinningLoader: () => <div data-testid="mock-spinning-loader" />
SpinningLoader: () => <></>,
}));
};

export const mockUseLanguageSelector = () => {
jest.mock('../components/Common/LanguageSelector', () => ({
LanguageSelector: () => <div data-testid="mock-language-selector" />
LanguageSelector: () => <></>,
}));
};

Expand All @@ -139,4 +132,4 @@ export const renderWithProvider = (
</Provider>,
options
);
};
};
3 changes: 2 additions & 1 deletion inji-web/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export enum MethodType {
export class api {

// static mimotoHost = "http://localhost:3010";
static mimotoHost = window.location.origin + "/v1/mimoto";
// static mimotoHost = window.location.origin + "/v1/mimoto";
static mimotoHost="https://api.collab.mossip.net" + "/v1/mimoto";

static authorizationRedirectionUrl = window.location.origin + "/redirect";

Expand Down

0 comments on commit 05557e4

Please sign in to comment.