fix(core): Fix concurrency and download handling in HandelsRegister class and adjust test cases

This commit is contained in:
2025-01-07 05:06:16 +01:00
parent a19be31381
commit ec2d4f9fbc
7 changed files with 166 additions and 116 deletions

View File

@ -1,6 +1,11 @@
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import { tapNodeTools } from '@push.rocks/tapbundle/node';
import * as opendata from '../ts/index.js'
import { BusinessRecord } from '../ts/classes.businessrecord.js';
let testOpenDataInstance: opendata.OpenData;
tap.test('first test', async () => {
@ -12,22 +17,28 @@ tap.test('should start the instance', async () => {
await testOpenDataInstance.start();
})
tap.test('should build initial data', async () => {
tap.skip.test('should build initial data', async () => {
await testOpenDataInstance.buildInitialDb();
});
const resultsSearch = tap.test('should get the data for a company', async () => {
const result = await testOpenDataInstance.handelsregister.searchCompany('Volkswagen');
const result = await testOpenDataInstance.handelsregister.searchCompany('Volkswagen', 20);
console.log(result);
return result;
});
tap.test('should get the data for a specific company', async () => {
const testCompany = (await resultsSearch.testResultPromise)[21]['germanParsedRegistration'];
let testCompany: BusinessRecord['data']['germanParsedRegistration'] = (await resultsSearch.testResultPromise)[8]['germanParsedRegistration'];
console.log(`trying to find specific company with:`);
console.log(testCompany);
const result = await testOpenDataInstance.handelsregister.getSpecificCompany(testCompany);
console.log(result);
result.files.map(async (file) => {
await file.writeToDir('./.nogit/testoutput');
});
});
tap.test('should stop the instance', async () => {