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 filepath = path.join(__dirname, `./fixtures/${test.filename}`);
let options = test.options;
let expectedRecordCount = test.recordCount;
let expectedFirstRecord: Record | undefined = test.firstRecord;
let expectedLastRecord: Record | undefined = test.lastRecord;
let expectedDeletedCount = test.deletedCount;
let expectedError = test.error;
try {
let dbf = await DBFFile.open(filepath, options);
let records = await dbf.readRecords();
expect(dbf.recordCount, 'the record count should match').equals(expectedRecordCount);
expect(records[0], 'first record should match').to.deep.include(expectedFirstRecord!);
expect(records[records.length - 1], 'last record should match').to.deep.include(expectedLastRecord!);
expect(dbf.recordCount - records.length, 'deleted records should match').equals(expectedDeletedCount);
}
catch (err) {
expect(err.message).equals(expectedError);
return;
}
expect(undefined).equals(expectedError);
});
});
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);
});
});
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);
});
});
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);
});
});