aboutsummaryrefslogtreecommitdiff
path: root/tests/frames.test.ts
diff options
context:
space:
mode:
authorPriyansh <[email protected]>2022-01-19 00:57:06 -0500
committerPriyansh <[email protected]>2022-01-19 00:57:06 -0500
commit80eabe37c21ae4965dbafbb9abb5c7a153b209c5 (patch)
tree913376ae548fecbe72b2099fa006f81d50dbb5ab /tests/frames.test.ts
parentbc6fa1856be7ec26208bb2c4c63b693a163506c3 (diff)
downloadizuku.js-80eabe37c21ae4965dbafbb9abb5c7a153b209c5.tar.xz
izuku.js-80eabe37c21ae4965dbafbb9abb5c7a153b209c5.zip
feat: display data in table function
Diffstat (limited to 'tests/frames.test.ts')
-rw-r--r--tests/frames.test.ts61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/frames.test.ts b/tests/frames.test.ts
new file mode 100644
index 0000000..b643292
--- /dev/null
+++ b/tests/frames.test.ts
@@ -0,0 +1,61 @@
+import { expect } from 'chai';
+import { Frame } from '../src/index';
+
+describe('frames.ts', () => {
+ describe('Create a new frame with column names', () => {
+ it('should create a new frame', () => {
+ const newframe = new Frame([
+ ['a', 'b', 'c'],
+ ['d', 'e', 'f'],
+ ['g', 'h', 'i']
+ ]);
+ expect(newframe.rowdata).to.deep.equal([
+ ['a', 'b', 'c'],
+ ['d', 'e', 'f'],
+ ['g', 'h', 'i']
+ ]);
+ newframe.header(['a', 'b', 'c']);
+ expect(newframe.columns).to.deep.equal(['a', 'b', 'c']);
+ });
+ });
+ describe('Update a frame and column names', () => {
+ it('should update a frame', () => {
+ const newframe = new Frame([
+ ['a', 'b', 'c'],
+ ['d', 'e', 'f'],
+ ['g', 'h', 'i']
+ ]);
+ newframe.header(['a', 'b', 'c']);
+ expect(newframe.rowdata).to.deep.equal([
+ ['a', 'b', 'c'],
+ ['d', 'e', 'f'],
+ ['g', 'h', 'i']
+ ]);
+ expect(newframe.columns).to.deep.equal(['a', 'b', 'c']);
+ newframe.data([
+ ['j', 'k', 'l'],
+ ['m', 'n', 'o'],
+ ['p', 'q', 'r']
+ ]);
+ newframe.header(['j', 'k', 'l']);
+ expect(newframe.rowdata).to.deep.equal([
+ ['j', 'k', 'l'],
+ ['m', 'n', 'o'],
+ ['p', 'q', 'r']
+ ]);
+ expect(newframe.columns).to.deep.equal(['j', 'k', 'l']);
+ });
+ });
+ describe('Print a frame', () => {
+ it('should print a frame', () => {
+ const header = ['Name', 'Age', 'Gender', 'Country'];
+ const data = [
+ ['Arthur', 21, 'Male', 'USA'],
+ ['Betty', 20, 'Female', 'Canada'],
+ ['Victor', 25, 'Male']
+ ];
+ const newframe = new Frame(data, header);
+ newframe.data();
+ });
+ });
+});