Skip to content

Commit 960855c

Browse files
committed
Migrated CSV parser tests to 'assert'
no issue - Using native 'assert' module in unit tests is a preferred practice. Should is outdated and is phased out of codebase.
1 parent b2f2511 commit 960855c

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

packages/members-csv/test/parse.test.js

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const should = require('should');
21
const path = require('path');
32
const assert = require('assert');
43
const {parse} = require('../index');
@@ -14,36 +13,36 @@ describe('parse', function () {
1413
const filePath = csvPath + 'empty.csv';
1514
const result = await parse(filePath, DEFAULT_HEADER_MAPPING);
1615

17-
should.exist(result);
18-
result.length.should.eql(0);
16+
assert.ok(result);
17+
assert.equal(result.length, 0);
1918
});
2019

2120
it('one column', async function () {
2221
const filePath = csvPath + 'single-column-with-header.csv';
2322
const result = await parse(filePath, DEFAULT_HEADER_MAPPING);
2423

25-
should.exist(result);
26-
result.length.should.eql(2);
27-
result[0].email.should.eql('[email protected]');
28-
result[1].email.should.eql('[email protected]');
24+
assert.ok(result);
25+
assert.equal(result.length, 2);
26+
assert.equal(result[0].email, '[email protected]');
27+
assert.equal(result[1].email, '[email protected]');
2928
});
3029

3130
it('one column without header mapping returns empty result', async function () {
3231
const filePath = csvPath + 'single-column-with-header.csv';
3332
const result = await parse(filePath);
3433

35-
should.exist(result);
36-
result.length.should.eql(0);
34+
assert.ok(result);
35+
assert.equal(result.length, 0);
3736
});
3837

3938
it('two columns, 1 filter', async function () {
4039
const filePath = csvPath + 'two-columns-with-header.csv';
4140
const result = await parse(filePath, DEFAULT_HEADER_MAPPING);
4241

43-
should.exist(result);
44-
result.length.should.eql(2);
45-
result[0].email.should.eql('[email protected]');
46-
result[1].email.should.eql('[email protected]');
42+
assert.ok(result);
43+
assert.equal(result.length, 2);
44+
assert.equal(result[0].email, '[email protected]');
45+
assert.equal(result[1].email, '[email protected]');
4746
});
4847

4948
it('two columns, 2 filters', async function () {
@@ -54,12 +53,12 @@ describe('parse', function () {
5453
};
5554
const result = await parse(filePath, mapping);
5655

57-
should.exist(result);
58-
result.length.should.eql(2);
59-
result[0].email.should.eql('[email protected]');
60-
result[0].id.should.eql('1');
61-
result[1].email.should.eql('[email protected]');
62-
result[1].id.should.eql('2');
56+
assert.ok(result);
57+
assert.equal(result.length, 2);
58+
assert.equal(result[0].email, '[email protected]');
59+
assert.equal(result[0].id, '1');
60+
assert.equal(result[1].email, '[email protected]');
61+
assert.equal(result[1].id, '2');
6362
});
6463

6564
it('two columns with mapping', async function () {
@@ -71,15 +70,15 @@ describe('parse', function () {
7170
};
7271
const result = await parse(filePath, mapping);
7372

74-
should.exist(result);
75-
result.length.should.eql(2);
76-
result[0].email.should.eql('[email protected]');
77-
result[0].name.should.eql('joe');
78-
result[0].id.should.eql('1');
73+
assert.ok(result);
74+
assert.equal(result.length, 2);
75+
assert.equal(result[0].email, '[email protected]');
76+
assert.equal(result[0].name, 'joe');
77+
assert.equal(result[0].id, '1');
7978

80-
result[1].email.should.eql('[email protected]');
81-
result[1].name.should.eql('test');
82-
result[1].id.should.eql('2');
79+
assert.equal(result[1].email, '[email protected]');
80+
assert.equal(result[1].name, 'test');
81+
assert.equal(result[1].id, '2');
8382
});
8483

8584
it('two columns with partial mapping', async function () {
@@ -90,26 +89,26 @@ describe('parse', function () {
9089
};
9190
const result = await parse(filePath, mapping);
9291

93-
should.exist(result);
94-
result.length.should.eql(2);
95-
result[0].email.should.eql('[email protected]');
96-
result[0].id.should.eql('1');
92+
assert.ok(result);
93+
assert.equal(result.length, 2);
94+
assert.equal(result[0].email, '[email protected]');
95+
assert.equal(result[0].id, '1');
9796

98-
result[1].email.should.eql('[email protected]');
99-
result[1].id.should.eql('2');
97+
assert.equal(result[1].email, '[email protected]');
98+
assert.equal(result[1].id, '2');
10099
});
101100

102101
it('transforms empty values to nulls', async function () {
103102
const filePath = csvPath + 'multiple-records-with-empty-values.csv';
104103
const result = await parse(filePath, DEFAULT_HEADER_MAPPING);
105104

106-
should.exist(result);
107-
result.length.should.eql(2);
108-
result[0].email.should.eql('[email protected]');
109-
result[0].name.should.eql('Bob');
105+
assert.ok(result);
106+
assert.equal(result.length, 2);
107+
assert.equal(result[0].email, '[email protected]');
108+
assert.equal(result[0].name, 'Bob');
110109

111-
result[1].email.should.eql('[email protected]');
112-
should.equal(result[1].name, null);
110+
assert.equal(result[1].email, '[email protected]');
111+
assert.equal(result[1].name, null);
113112
});
114113

115114
it(' transforms "subscribed_to_emails" column to "subscribed" property when the mapping is passed in', async function () {

0 commit comments

Comments
 (0)