aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPriyansh <[email protected]>2022-01-22 21:33:06 -0500
committerPriyansh <[email protected]>2022-01-22 21:33:06 -0500
commit6156ba8bc5481e6ae916bc1aebea0651c257dff8 (patch)
tree06056f0d47229b6dca1d81e790a0880ac0d058d9 /tests
parent35a5843b68710e8bcde949d5c2e2f472dbb325e4 (diff)
downloadizuku.js-6156ba8bc5481e6ae916bc1aebea0651c257dff8.tar.xz
izuku.js-6156ba8bc5481e6ae916bc1aebea0651c257dff8.zip
feat: function to load data from json and flattenJSON
Diffstat (limited to 'tests')
-rw-r--r--tests/data.test.ts44
-rw-r--r--tests/support/users.json34
2 files changed, 78 insertions, 0 deletions
diff --git a/tests/data.test.ts b/tests/data.test.ts
new file mode 100644
index 0000000..33eb56f
--- /dev/null
+++ b/tests/data.test.ts
@@ -0,0 +1,44 @@
+import { Frame } from '../src/index';
+import { expect } from 'chai';
+import JSONData from './support/users.json';
+
+describe('data.ts', () => {
+ describe('load frame from json file', () => {
+ it('should load the frame from json file', () => {
+ const dataToExpect = [
+ [
+ 1,
+ 'Jeanette',
+ 'Penddreth',
+ 'Female',
+ '26.58.193.2'
+ ],
+ [
+ 2,
+ 'Giavani',
+ 'Frediani',
+ 'Male',
+ '229.179.4.212'
+ ],
+ [3, 'Noell', 'Bea', '[email protected]', 'Female', '180.66.162.255'],
+ [4, 'Willard', 'Valek', '[email protected]', 'Male', '67.76.188.26']
+ ];
+ const headerToExpect = [
+ 'id',
+ 'first_name',
+ 'last_name',
+ 'email',
+ 'gender',
+ 'ip_address'
+ ];
+ expect(new Frame().fromJSON(JSONData).columns).to.deep.equal(
+ headerToExpect
+ );
+ expect(new Frame().fromJSON(JSONData).rowdata).to.deep.equal(
+ dataToExpect
+ );
+ });
+ });
+});
diff --git a/tests/support/users.json b/tests/support/users.json
new file mode 100644
index 0000000..628e8f5
--- /dev/null
+++ b/tests/support/users.json
@@ -0,0 +1,34 @@
+[
+ {
+ "id": 1,
+ "first_name": "Jeanette",
+ "last_name": "Penddreth",
+ "email": "[email protected]",
+ "gender": "Female",
+ "ip_address": "26.58.193.2"
+ },
+ {
+ "id": 2,
+ "first_name": "Giavani",
+ "last_name": "Frediani",
+ "email": "[email protected]",
+ "gender": "Male",
+ "ip_address": "229.179.4.212"
+ },
+ {
+ "id": 3,
+ "first_name": "Noell",
+ "last_name": "Bea",
+ "email": "[email protected]",
+ "gender": "Female",
+ "ip_address": "180.66.162.255"
+ },
+ {
+ "id": 4,
+ "first_name": "Willard",
+ "last_name": "Valek",
+ "email": "[email protected]",
+ "gender": "Male",
+ "ip_address": "67.76.188.26"
+ }
+]