mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-13 14:41:02 +00:00
Add moduleNameMapper for shared lib mocks in Jest
Create dedicated mock files for shared/lib modules and map them in moduleNameMapper for reliable module resolution in CI. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
// Mock for shared/lib/referral.ts
|
||||||
|
module.exports = {
|
||||||
|
initiateReferral: jest.fn(() => Promise.resolve()),
|
||||||
|
getPendingReferral: jest.fn(() => Promise.resolve(null)),
|
||||||
|
getReferralCount: jest.fn(() => Promise.resolve(0)),
|
||||||
|
getReferralInfo: jest.fn(() => Promise.resolve(null)),
|
||||||
|
calculateReferralScore: jest.fn(() => 0),
|
||||||
|
getReferralStats: jest.fn(() => Promise.resolve({ totalReferred: 0, pendingCount: 0, confirmedCount: 0 })),
|
||||||
|
getMyReferrals: jest.fn(() => Promise.resolve([])),
|
||||||
|
subscribeToReferralEvents: jest.fn(() => jest.fn()),
|
||||||
|
};
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// Mock for shared/lib/scores.ts
|
||||||
|
module.exports = {
|
||||||
|
getTrustScore: jest.fn(() => Promise.resolve(0)),
|
||||||
|
getTrustScoreDetails: jest.fn(() => Promise.resolve(null)),
|
||||||
|
getReferralScore: jest.fn(() => Promise.resolve(0)),
|
||||||
|
getReferralCount: jest.fn(() => Promise.resolve(0)),
|
||||||
|
getStakingScoreFromPallet: jest.fn(() => Promise.resolve(0)),
|
||||||
|
getTikiScore: jest.fn(() => Promise.resolve(0)),
|
||||||
|
getAllScores: jest.fn(() =>
|
||||||
|
Promise.resolve({
|
||||||
|
trustScore: 0,
|
||||||
|
referralScore: 0,
|
||||||
|
stakingScore: 0,
|
||||||
|
tikiScore: 0,
|
||||||
|
totalScore: 0,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
getScoreColor: jest.fn(() => '#22C55E'),
|
||||||
|
getScoreRating: jest.fn(() => 'Good'),
|
||||||
|
formatScore: jest.fn((score) => String(score)),
|
||||||
|
};
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Mock for shared/lib/tiki.ts
|
||||||
|
module.exports = {
|
||||||
|
Tiki: {
|
||||||
|
Welati: 'Welati',
|
||||||
|
Parlementer: 'Parlementer',
|
||||||
|
SerokiMeclise: 'SerokiMeclise',
|
||||||
|
Serok: 'Serok',
|
||||||
|
EndameDiwane: 'EndameDiwane',
|
||||||
|
Dadger: 'Dadger',
|
||||||
|
Dozger: 'Dozger',
|
||||||
|
Hiquqnas: 'Hiquqnas',
|
||||||
|
Noter: 'Noter',
|
||||||
|
Wezir: 'Wezir',
|
||||||
|
},
|
||||||
|
RoleAssignmentType: {},
|
||||||
|
TIKI_DISPLAY_NAMES: {},
|
||||||
|
TIKI_SCORES: {},
|
||||||
|
ROLE_CATEGORIES: {},
|
||||||
|
fetchUserTikis: jest.fn(() => Promise.resolve([])),
|
||||||
|
isCitizen: jest.fn(() => Promise.resolve(false)),
|
||||||
|
calculateTikiScore: jest.fn(() => 0),
|
||||||
|
getPrimaryRole: jest.fn(() => 'Welati'),
|
||||||
|
getTikiDisplayName: jest.fn((tiki) => tiki),
|
||||||
|
getUserRoleCategories: jest.fn(() => []),
|
||||||
|
hasTiki: jest.fn(() => false),
|
||||||
|
getTikiColor: jest.fn(() => '#22C55E'),
|
||||||
|
getTikiEmoji: jest.fn(() => '\uD83D\uDC64'),
|
||||||
|
getTikiBadgeVariant: jest.fn(() => 'default'),
|
||||||
|
fetchUserTikiNFTs: jest.fn(() => Promise.resolve([])),
|
||||||
|
getCitizenNFTDetails: jest.fn(() => Promise.resolve(null)),
|
||||||
|
getAllTikiNFTDetails: jest.fn(() => Promise.resolve([])),
|
||||||
|
generateCitizenNumber: jest.fn(() => 'CIT-001'),
|
||||||
|
};
|
||||||
@@ -12,6 +12,10 @@ module.exports = {
|
|||||||
'react-native-reanimated': '<rootDir>/__mocks__/react-native-reanimated.js',
|
'react-native-reanimated': '<rootDir>/__mocks__/react-native-reanimated.js',
|
||||||
'^sonner$': '<rootDir>/__mocks__/sonner.js',
|
'^sonner$': '<rootDir>/__mocks__/sonner.js',
|
||||||
'@polkadot/extension-dapp': '<rootDir>/__mocks__/polkadot-extension-dapp.js',
|
'@polkadot/extension-dapp': '<rootDir>/__mocks__/polkadot-extension-dapp.js',
|
||||||
|
// Mock shared lib modules that depend on @pezkuwi/api
|
||||||
|
'^.*/shared/lib/tiki$': '<rootDir>/__mocks__/shared-lib-tiki.js',
|
||||||
|
'^.*/shared/lib/referral$': '<rootDir>/__mocks__/shared-lib-referral.js',
|
||||||
|
'^.*/shared/lib/scores$': '<rootDir>/__mocks__/shared-lib-scores.js',
|
||||||
},
|
},
|
||||||
testMatch: ['**/__tests__/**/*.test.(ts|tsx|js)'],
|
testMatch: ['**/__tests__/**/*.test.(ts|tsx|js)'],
|
||||||
collectCoverageFrom: [
|
collectCoverageFrom: [
|
||||||
|
|||||||
Reference in New Issue
Block a user