[INJIMOB-3303]: fix failing test (#1978)

Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
Co-authored-by: Alka Prasad <prasadalka1998@gmail.com>
This commit is contained in:
abhip2565
2025-06-24 18:52:18 +05:30
committed by GitHub
parent 8e16155974
commit 6ce679313f
5 changed files with 38 additions and 25 deletions

View File

@@ -0,0 +1,4 @@
import {TextDecoder, TextEncoder} from 'text-encoding';
global.TextDecoder = TextDecoder;
global.TextEncoder = TextEncoder;

View File

@@ -1,10 +1,14 @@
import {VCActivityLog} from './ActivityLogEvent';
describe('ActivityLog', () => {
let instance: { timestamp: any; };
let instance: {timestamp: any};
beforeEach(() => {
instance = new VCActivityLog();
jest.mock('jsonld', () => ({
compact: jest.fn(),
expand: jest.fn(),
}));
});
it('Activity log instance should have a timestamp set', () => {
@@ -16,28 +20,32 @@ describe('getActionText', () => {
let activityLog;
let mockIl18nfn;
let wellknown = {
"credential_configurations_supported": {
"mockId": {
"display": [
credential_configurations_supported: {
mockId: {
display: [
{
"name": "fake VC",
"locale": "en",
"logo": {
"url": "https://mosip.github.io/inji-config/logos/mosipid-logo.png",
"alt_text": "a square logo of a MOSIP"
name: 'fake VC',
locale: 'en',
logo: {
url: 'https://mosip.github.io/inji-config/logos/mosipid-logo.png',
alt_text: 'a square logo of a MOSIP',
},
"background_color": "#1A0983",
"background_image": {
"uri": "https://mosip.github.io/inji-config/logos/mosipid-logo.png"
background_color: '#1A0983',
background_image: {
uri: 'https://mosip.github.io/inji-config/logos/mosipid-logo.png',
},
"text_color": "#000000"
}
text_color: '#000000',
},
],
}
}
}
},
},
};
beforeEach(() => {
mockIl18nfn = jest.fn();
jest.mock('jsonld', () => ({
compact: jest.fn(),
expand: jest.fn(),
}));
activityLog = new VCActivityLog({
id: 'mockId',
credentialConfigurationId: 'mockId',
@@ -58,7 +66,7 @@ describe('getActionText', () => {
});
activityLog.getActionText(mockIl18nfn, wellknown);
expect(mockIl18nfn).toHaveBeenCalledWith('mockType', {
idType: 'fake VC'
idType: 'fake VC',
});
expect(mockIl18nfn).toHaveBeenCalledTimes(1);
// TODO: assert the returned string

View File

@@ -28,11 +28,11 @@ module.exports = {
// Not quite sure about the reason.
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$',
coveragePathIgnorePatterns: [
"node_modules",
"test-config",
"interfaces",
"jestGlobalMocks.ts",
"__mocks__/*"
'node_modules',
'test-config',
'interfaces',
'jestGlobalMocks.ts',
'__mocks__/*',
],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)',
@@ -53,6 +53,7 @@ module.exports = {
'<rootDir>/__mocks__/@noble/mock-ed25519.js',
'<rootDir>/__mocks__/react-native-base64.js',
'<rootDir>__mocks__/mockCrytoUtil.js',
'<rootDir>__mocks__/text-encoder.js',
// https://github.com/react-native-google-signin/google-signin?tab=readme-ov-file#jest-module-mock
'<rootDir>/node_modules/@react-native-google-signin/google-signin/jest/build/setup.js',
],

2
package-lock.json generated
View File

@@ -102,7 +102,6 @@
"short-unique-id": "^4.4.4",
"simple-pem2jwk": "^0.2.4",
"telemetry-sdk": "git://github.com/mosip/sunbird-telemetry-sdk.git#f762be5732ee552c0c70bdd540aa4e2701554c71",
"text-encoding": "^0.7.0",
"uuid": "^11.0.3",
"xstate": "^4.35.0"
},
@@ -146,6 +145,7 @@
"react-native-share": "^10.2.1",
"react-native-svg-transformer": "^1.1.0",
"react-native-url-polyfill": "^2.0.0",
"text-encoding": "^0.7.0",
"ts-jest": "^29.1.1",
"typescript": "~5.3.3"
},

View File

@@ -107,7 +107,6 @@
"short-unique-id": "^4.4.4",
"simple-pem2jwk": "^0.2.4",
"telemetry-sdk": "git://github.com/mosip/sunbird-telemetry-sdk.git#f762be5732ee552c0c70bdd540aa4e2701554c71",
"text-encoding": "^0.7.0",
"uuid": "^11.0.3",
"xstate": "^4.35.0"
},
@@ -151,6 +150,7 @@
"react-native-share": "^10.2.1",
"react-native-svg-transformer": "^1.1.0",
"react-native-url-polyfill": "^2.0.0",
"text-encoding": "^0.7.0",
"ts-jest": "^29.1.1",
"typescript": "~5.3.3"
},