UNPKG

@infect/infect-rda-sample-importer

Version:
59 lines (40 loc) 2 kB
import assert from 'assert'; import section from 'section-tests'; import path from 'path'; import RainbowConfig from '@rainbow-industries/rainbow-config'; import PatientSexProcessor from '../src/lib/field/PatientSexProcessor.js'; import HTTP2Client from '@distributed-systems/http2-client'; section.continue('Field Processors', (section) => { section('PatientSexProcessor', (section) => { section.test('invalid 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 PatientSexProcessor({ httpClient, }); const value = await processor.process(1).catch(err => 1); assert.equal(value, 1); }); section.test('valid 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 PatientSexProcessor({ httpClient, }); const value = await processor.process(' M'); assert.equal(value, 1); }); }); });