UNPKG

@infect/infect-rda-sample-importer

Version:
52 lines (37 loc) 1.48 kB
import APILookup from '../src/APILookup.js'; import section from 'section-tests'; import assert from 'assert'; import path from 'path'; import ServiceManager from '@infect/rda-service-manager'; import RainbowConfig from '@rainbow-industries/rainbow-config'; import HTTP2Client from '@distributed-systems/http2-client'; section('API Lookup', (section) => { let sm; section.setup(async () => { sm = new ServiceManager({ args: '--dev --log-level=error+ --log-module=* --data-for-dev'.split(' ') }); await sm.startServices('@infect/api'); }); section.test('Get 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 lookup = new APILookup({ httpClient, resource: 'substance.compound', filterProperty: 'identifier', selectionField: 'name', }); const value = await lookup.get('amoxicillin'); assert.equal(value, 'Amoxicillin'); }); section.destroy(async () => { sm.stopServices(); }); });