Skip to content

Commit

Permalink
Add tests for user-specified indexed table creation using arrow data
Browse files Browse the repository at this point in the history
  • Loading branch information
nmichaud committed Feb 1, 2018
1 parent 13608f6 commit 3475cbc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/perspective/test/js/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ var arrow_result = [
{"f32": 5.5, "f64": 5.5, "i64": 5, "i32": 5, "i16": 5, "i8": 5, "bool": true, "char": "d", "dict": "d", "datetime": +(new Date("2018-01-29"))}
];

var arrow_indexed_result = [
{"f32": 1.5, "f64": 1.5, "i64": 1, "i32": 1, "i16": 1, "i8": 1, "bool": true, "char": "a", "dict": "a", "datetime": +(new Date("2018-01-25"))},
{"f32": 2.5, "f64": 2.5, "i64": 2, "i32": 2, "i16": 2, "i8": 2, "bool": false, "char": "b", "dict": "b", "datetime": +(new Date("2018-01-26"))},
{"f32": 3.5, "f64": 3.5, "i64": 3, "i32": 3, "i16": 3, "i8": 3, "bool": true, "char": "c", "dict": "c", "datetime": +(new Date("2018-01-27"))},
{"f32": 5.5, "f64": 5.5, "i64": 5, "i32": 5, "i16": 5, "i8": 5, "bool": true, "char": "d", "dict": "d", "datetime": +(new Date("2018-01-29"))}
];


module.exports = (perspective) => {

describe("Updates", function() {
Expand Down Expand Up @@ -157,6 +165,27 @@ module.exports = (perspective) => {
expect(data).toEqual(result);
});

it("Arrow with {index: 'i64'} (int)", async function () {
var table = perspective.table(arrow, {index: 'i64'});
var view = table.view();
let result = await view.to_json();
expect(arrow_result).toEqual(result);
});

it("Arrow with {index: 'char'} (char)", async function () {
var table = perspective.table(arrow, {index: 'char'});
var view = table.view();
let result = await view.to_json();
expect(arrow_indexed_result).toEqual(result);
});

it("Arrow with {index: 'dict'} (dict)", async function () {
var table = perspective.table(arrow, {index: 'dict'});
var view = table.view();
let result = await view.to_json();
expect(arrow_indexed_result).toEqual(result);
});

it("multiple updates on {index: 'x'}", async function () {
var table = perspective.table(data, {index: 'x'});
var view = table.view();
Expand Down

0 comments on commit 3475cbc

Please sign in to comment.