Skip to content

Commit

Permalink
Adding DefaultRegistryClient unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelynJefferson committed Jul 2, 2024
1 parent 803ddfa commit ff3cfd2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/registry/DefaultRegistryClient.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { DefaultRegistryClient } from '../../src/registry/DefaultRegistryClient';
import { loggerSpy } from '../testhelpers';

describe('DefaultRegistryClient', () => {
describe('#constructor', () => {
beforeEach(() => {
loggerSpy.reset();
delete process.env.FPL_REGISTRY;
});
afterEach(() => {});

it('should make a custom registry client when specified', () => {
process.env.FPL_REGISTRY = 'https://custom-registry.example.org/';
new DefaultRegistryClient({ log: loggerSpy.log });
expect(loggerSpy.getLastMessage('info')).toBe(
'Using custom registry specified by FPL_REGISTRY environment variable: https://custom-registry.example.org/'
);
});

it('should use the first default set for a custom registry client when specified', () => {
process.env.FPL_REGISTRY = 'https://custom-registry.example.org/';
new DefaultRegistryClient({ log: loggerSpy.log });
// expect(loggerSpy.getLastMessage('info')).toBe('Using custom registry specified by FPL_REGISTRY environment variable: https://custom-registry.example.org/');

process.env.FPL_REGISTRY = 'https://custom-registry-second.example.org/';
new DefaultRegistryClient({ log: loggerSpy.log });
// expect(loggerSpy.getLastMessage('info')).toBe('Using custom registry specified by FPL_REGISTRY environment variable: https://custom-registry.example.org/');
});

it('should make a FHIR registry client when custom registry not specified', () => {
new DefaultRegistryClient({ log: loggerSpy.log });
expect(loggerSpy.getLastMessage('info')).toBeUndefined();
});
});
});

0 comments on commit ff3cfd2

Please sign in to comment.