aboutsummaryrefslogtreecommitdiff
path: root/tests/data.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/data.test.ts')
-rw-r--r--tests/data.test.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/data.test.ts b/tests/data.test.ts
index 33eb56f..d922a66 100644
--- a/tests/data.test.ts
+++ b/tests/data.test.ts
@@ -1,6 +1,7 @@
import { Frame } from '../src/index';
import { expect } from 'chai';
import JSONData from './support/users.json';
+import path = require('path');
describe('data.ts', () => {
describe('load frame from json file', () => {
@@ -41,4 +42,36 @@ describe('data.ts', () => {
);
});
});
+ describe('load data from a CSV file', () => {
+ it('should load data from a CSV file', () => {
+ const csvPath = path.join(__dirname, 'support', 'users.csv');
+ const firstRow = [
+ '1',
+ 'Durante',
+ 'Toma',
+ 'Female',
+ '55.96.246.188'
+ ];
+ const lastRow = [
+ '10',
+ 'Niki',
+ 'Ruos',
+ 'Female',
+ '110.74.213.22'
+ ];
+ const header = [
+ 'id',
+ 'first_name',
+ 'last_name',
+ 'email',
+ 'gender',
+ 'ip_address'
+ ];
+ expect(new Frame().fromCSV(csvPath).rowdata[0]).to.deep.equal(firstRow);
+ expect(new Frame().fromCSV(csvPath).rowdata[9]).to.deep.equal(lastRow);
+ expect(new Frame().fromCSV(csvPath).columns).to.deep.equal(header);
+ });
+ });
});