aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/frames.test.ts61
-rw-r--r--tests/frames.ts49
2 files changed, 61 insertions, 49 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();
+ });
+ });
+});
diff --git a/tests/frames.ts b/tests/frames.ts
deleted file mode 100644
index ff778c3..0000000
--- a/tests/frames.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { expect } from 'chai';
-import Izuku from '../src/index';
-
-describe('frames.ts', () => {
- describe('Create a new frame with column names', () => {
- it('should create a new frame', () => {
- const newframe = new Izuku([
- ['a', 'b', 'c'],
- ['d', 'e', 'f'],
- ['g', 'h', 'i']
- ]);
- expect(newframe.data()).to.deep.equal([
- ['a', 'b', 'c'],
- ['d', 'e', 'f'],
- ['g', 'h', 'i']
- ]);
- newframe.columns(['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 Izuku([
- ['a', 'b', 'c'],
- ['d', 'e', 'f'],
- ['g', 'h', 'i']
- ]);
- newframe.columns(['a', 'b', 'c']);
- expect(newframe.data()).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.columns(['j', 'k', 'l']);
- expect(newframe.data()).to.deep.equal([
- ['j', 'k', 'l'],
- ['m', 'n', 'o'],
- ['p', 'q', 'r']
- ]);
- expect(newframe.columns()).to.deep.equal(['j', 'k', 'l']);
- });
- });
-});