Skip to content

Commit

Permalink
Add mock ConfigService to oracle-discovery service test.
Browse files Browse the repository at this point in the history
  • Loading branch information
MWBlocky committed May 9, 2024
1 parent 1274ff3 commit a2134ad
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../model/oracle-discovery.model';
import { EnvironmentConfigService } from '../../../common/config/environment-config.service';
import { CommonConfigModule } from '../../../common/config/common-config.module';
import { ConfigModule } from '@nestjs/config';
import { ConfigModule, ConfigService } from '@nestjs/config';

jest.mock('@human-protocol/sdk', () => ({
OperatorUtils: {
Expand All @@ -23,6 +23,17 @@ describe('OracleDiscoveryService', () => {
let cacheManager: Cache;
let configService: EnvironmentConfigService;

const mockConfigService = {
getOrThrow: jest.fn().mockImplementation((key: string) => {
switch (key) {
case 'REPUTATION_ORACLE_ADDRESS':
return 'Mock_Reputation_Oracle_Address';
default:
return null;
}
}),
};

beforeEach(async () => {
const moduleRef = await Test.createTestingModule({
imports: [
Expand All @@ -41,6 +52,10 @@ describe('OracleDiscoveryService', () => {
set: jest.fn(),
},
},
{
provide: ConfigService,
useValue: mockConfigService,
},
],
}).compile();
configService = moduleRef.get<EnvironmentConfigService>(
Expand Down

0 comments on commit a2134ad

Please sign in to comment.