@infect/infect-rda-sample-importer
Version:
INFECT Sample Data Importer
77 lines (55 loc) • 2.77 kB
JavaScript
import assert from 'assert';
import section from 'section-tests';
import path from 'path';
import RainbowConfig from '@rainbow-industries/rainbow-config';
import PatientSettingProcessor from '../src/lib/field/PatientSettingProcessor.js'
import HTTP2Client from '@distributed-systems/http2-client';
section.continue('Field Processors', (section) => {
section('PatientSettingProcessor', (section) => {
section.test('invald value', async() => {
const configDir = path.join(path.dirname(new URL(import.meta.url).pathname), '../');
const config = new RainbowConfig();
await config.load(configDir);
const httpClient = new HTTP2Client({
requestsPerSessionPerSecond: config.get('api-lookup.max-requests-per-second'),
maxConcurrentRequests: config.get('api-lookup.max-concurrent-requests'),
});
httpClient.host(config.get('core-data.host'));
const processor = new PatientSettingProcessor({
httpClient,
});
const value = await processor.process(1).catch(err => 1);
assert.equal(value, 1);
});
section.test('valid value: outpatient', async() => {
const configDir = path.join(path.dirname(new URL(import.meta.url).pathname), '../');
const config = new RainbowConfig();
await config.load(configDir);
const httpClient = new HTTP2Client({
requestsPerSessionPerSecond: config.get('api-lookup.max-requests-per-second'),
maxConcurrentRequests: config.get('api-lookup.max-concurrent-requests'),
});
httpClient.host(config.get('core-data.host'));
const processor = new PatientSettingProcessor({
httpClient,
});
const value = await processor.process('outpatient');
assert.equal(value, 2);
});
section.test('valid value: inpatient', async() => {
const configDir = path.join(path.dirname(new URL(import.meta.url).pathname), '../');
const config = new RainbowConfig();
await config.load(configDir);
const httpClient = new HTTP2Client({
requestsPerSessionPerSecond: config.get('api-lookup.max-requests-per-second'),
maxConcurrentRequests: config.get('api-lookup.max-concurrent-requests'),
});
httpClient.host(config.get('core-data.host'));
const processor = new PatientSettingProcessor({
httpClient,
});
const value = await processor.process(' inPatient');
assert.equal(value, 1);
});
});
});