1
- const should = require ( 'should' ) ;
2
1
const path = require ( 'path' ) ;
3
2
const assert = require ( 'assert' ) ;
4
3
const { parse} = require ( '../index' ) ;
@@ -14,36 +13,36 @@ describe('parse', function () {
14
13
const filePath = csvPath + 'empty.csv' ;
15
14
const result = await parse ( filePath , DEFAULT_HEADER_MAPPING ) ;
16
15
17
- should . exist ( result ) ;
18
- result . length . should . eql ( 0 ) ;
16
+ assert . ok ( result ) ;
17
+ assert . equal ( result . length , 0 ) ;
19
18
} ) ;
20
19
21
20
it ( 'one column' , async function ( ) {
22
21
const filePath = csvPath + 'single-column-with-header.csv' ;
23
22
const result = await parse ( filePath , DEFAULT_HEADER_MAPPING ) ;
24
23
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] ' ) ;
29
28
} ) ;
30
29
31
30
it ( 'one column without header mapping returns empty result' , async function ( ) {
32
31
const filePath = csvPath + 'single-column-with-header.csv' ;
33
32
const result = await parse ( filePath ) ;
34
33
35
- should . exist ( result ) ;
36
- result . length . should . eql ( 0 ) ;
34
+ assert . ok ( result ) ;
35
+ assert . equal ( result . length , 0 ) ;
37
36
} ) ;
38
37
39
38
it ( 'two columns, 1 filter' , async function ( ) {
40
39
const filePath = csvPath + 'two-columns-with-header.csv' ;
41
40
const result = await parse ( filePath , DEFAULT_HEADER_MAPPING ) ;
42
41
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] ' ) ;
47
46
} ) ;
48
47
49
48
it ( 'two columns, 2 filters' , async function ( ) {
@@ -54,12 +53,12 @@ describe('parse', function () {
54
53
} ;
55
54
const result = await parse ( filePath , mapping ) ;
56
55
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' ) ;
63
62
} ) ;
64
63
65
64
it ( 'two columns with mapping' , async function ( ) {
@@ -71,15 +70,15 @@ describe('parse', function () {
71
70
} ;
72
71
const result = await parse ( filePath , mapping ) ;
73
72
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' ) ;
79
78
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' ) ;
83
82
} ) ;
84
83
85
84
it ( 'two columns with partial mapping' , async function ( ) {
@@ -90,26 +89,26 @@ describe('parse', function () {
90
89
} ;
91
90
const result = await parse ( filePath , mapping ) ;
92
91
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' ) ;
97
96
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' ) ;
100
99
} ) ;
101
100
102
101
it ( 'transforms empty values to nulls' , async function ( ) {
103
102
const filePath = csvPath + 'multiple-records-with-empty-values.csv' ;
104
103
const result = await parse ( filePath , DEFAULT_HEADER_MAPPING ) ;
105
104
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' ) ;
110
109
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 ) ;
113
112
} ) ;
114
113
115
114
it ( ' transforms "subscribed_to_emails" column to "subscribed" property when the mapping is passed in' , async function ( ) {
0 commit comments