Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it(test.description, async () => {
let expectedRecordCount = test.recordCount;
let expectedFirstRecord: Record | undefined = test.firstRecord;
let expectedError = test.error;
try {
let srcPath = path.join(__dirname, `./fixtures/${test.filename}`);
let dstPath = path.join(__dirname, `./fixtures/${test.filename}.out`);
let srcDbf = await DBFFile.open(srcPath, test.options);
let dstDbf = await DBFFile.create(dstPath, srcDbf.fields.concat(test.newFields), test.options);
let records = await srcDbf.readRecords(100);
await dstDbf.appendRecords(records.map(test.newRecord));
dstDbf = await DBFFile.open(dstPath, test.options);
records = await dstDbf.readRecords(500);
expect(dstDbf.recordCount, 'the record count should match').equals(expectedRecordCount);
expect(records[0], 'first record should match').to.deep.include(expectedFirstRecord!);
}
catch (err) {
expect(err.message).equals(expectedError);
return;
}
expect(undefined).equals(expectedError);
});
});