Skip to content

Commit

Permalink
fix: handle falsy values in csv export
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfede authored and alovicu committed Jul 22, 2022
1 parent 5eba2f0 commit d3d967b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions test/ts/mongo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ describe('mongo', function () {
.expect('Content-Type', /text\/csv/)
.expect('Results-Matching', '4')
.then(({ text: data }) => {
data.should.equal('test2,11,\ntest1,13,true\ntest4,20,\ntest3,30,');
data.should.equal('test2,11,false\ntest1,13,true\ntest4,20,\ntest3,30,false');
});
});

Expand All @@ -626,7 +626,7 @@ describe('mongo', function () {
.expect('Content-Type', /text\/csv/)
.expect('Results-Matching', '4')
.then(({ text: data }) => {
data.should.equal('myid,y,z\ntest2,11,\ntest1,13,true\ntest4,20,\ntest3,30,');
data.should.equal('myid,y,z\ntest2,11,false\ntest1,13,true\ntest4,20,\ntest3,30,false');
});
});

Expand All @@ -637,7 +637,7 @@ describe('mongo', function () {
.expect('Content-Type', /text\/csv/)
.expect('Results-Matching', '4')
.then(({ text: data }) => {
data.should.equal('a,b,c\ntest2,11,\ntest1,13,true\ntest4,20,\ntest3,30,');
data.should.equal('a,b,c\ntest2,11,false\ntest1,13,true\ntest4,20,\ntest3,30,false');
});
});

Expand Down
8 changes: 4 additions & 4 deletions test/ts/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,20 @@ XXX,YYY`

it('should return the requested top level fields as csv, with empty fields', function () {
csv_options = {
fields: ['a', 'e', 'b'],
fields: ['a', 'e', 'b', 'c', 'd'],
};
csv_data = [
{ a: 'AAA', b: 'BBB', c: 1, d: true },
{ a: 'XXX', b: 'YYY', c: 1, d: false },
{ a: 'XXX', b: 'YYY', c: 0, d: false },
];
return request
.get('/tests')
.expect(200)
.expect('Content-Type', /text\/csv/)
.then(({ text: data }) => {
data.should.equal(
`AAA,,BBB
XXX,,YYY`
`AAA,,BBB,1,true
XXX,,YYY,0,false`
);
});
});
Expand Down

0 comments on commit d3d967b

Please sign in to comment.