diff options
Diffstat (limited to 'tests/frames.test.ts')
| -rw-r--r-- | tests/frames.test.ts | 61 |
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(); + }); + }); +}); |
