Skip to content

Commit 3427804

Browse files
committed
update tests
1 parent c3f8be3 commit 3427804

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

packages/compass-import-export/src/import/import-csv.spec.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,13 +777,19 @@ describe('importCSV', function () {
777777
const errors = errorCallback.args.map((args) => args[0]);
778778
for (const [index, error] of errors.entries()) {
779779
expect(error.op).to.exist;
780-
// cheat and copy them over because it is big and with buffers
781-
expectedErrors[index].op = error.op;
780+
expect(error).to.deep.contain(expectedErrors[index]);
781+
expect(error).to.have.nested.property('errInfo.details');
782782
}
783-
expect(errors).to.deep.equal(expectedErrors);
784783

785-
const errorsText = await fs.promises.readFile(output.path, 'utf8');
786-
expect(errorsText).to.equal(formatErrorLines(expectedErrors));
784+
const outputErrors = await fs.promises.readFile(output.path, 'utf8');
785+
const parsedOutputErrors = outputErrors
786+
.trim()
787+
.split('\n')
788+
.map((err) => JSON.parse(err));
789+
for (const [index, error] of parsedOutputErrors.entries()) {
790+
expect(error).to.deep.contain(expectedErrors[index]);
791+
expect(error).to.have.nested.property('errInfo.details');
792+
}
787793
});
788794

789795
it('responds to abortSignal.aborted', async function () {

packages/compass-import-export/src/import/import-json.spec.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,19 @@ describe('importJSON', function () {
555555
const errors = errorCallback.args.map((args) => args[0]);
556556
for (const [index, error] of errors.entries()) {
557557
expect(error.op).to.exist;
558-
// cheat and copy them over because it is big and with buffers
559-
expectedErrors[index].op = error.op;
558+
expect(error).to.deep.contain(expectedErrors[index]);
559+
expect(error).to.have.nested.property('errInfo.details');
560560
}
561-
expect(errors).to.deep.equal(expectedErrors);
562561

563-
const errorsText = await fs.promises.readFile(output.path, 'utf8');
564-
expect(errorsText).to.equal(formatErrorLines(expectedErrors));
562+
const outputErrors = await fs.promises.readFile(output.path, 'utf8');
563+
const parsedOutputErrors = outputErrors
564+
.trim()
565+
.split('\n')
566+
.map((err) => JSON.parse(err));
567+
for (const [index, error] of parsedOutputErrors.entries()) {
568+
expect(error).to.deep.contain(expectedErrors[index]);
569+
expect(error).to.have.nested.property('errInfo.details');
570+
}
565571
});
566572

567573
it('responds to abortSignal.aborted', async function () {

0 commit comments

Comments
 (0)