Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Mar 6, 2022
1 parent 06dd21c commit 0c97a68
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,3 @@ packages/perspective-jupyterlab/test/config/jupyter/lab
packages/perspective-jupyterlab/test/config/jupyter/migrated
docs/static/features
results.debug.json

boost*

.vs
62 changes: 62 additions & 0 deletions packages/perspective/test/js/pivots.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,68 @@ module.exports = (perspective) => {
table.delete();
});

it("['z'], last_minus_first", async function () {
var table = await perspective.table(
[
{x: 1, y: "a", z: true},
{x: 2, y: "b", z: false},
{x: 3, y: "c", z: true},
{x: 4, y: "d", z: false},
],
{index: "y"}
);
var view = await table.view({
group_by: ["z"],
columns: ["x"],
aggregates: {x: "last minus first"},
});
const answer = [
{__ROW_PATH__: [], x: -1},
{__ROW_PATH__: [false], x: 2},
{__ROW_PATH__: [true], x: -2},
];
table.update({
x: [5],
y: ["a"],
z: [true],
});
const result = await view.to_json();
expect(result).toEqual(answer);
view.delete();
table.delete();
});

it("['z'], high_minus_low", async function () {
var table = await perspective.table(
[
{x: 1, y: "a", z: true},
{x: 2, y: "b", z: false},
{x: 3, y: "c", z: true},
{x: 4, y: "d", z: false},
],
{index: "y"}
);
var view = await table.view({
group_by: ["z"],
columns: ["x"],
aggregates: {x: "high minus low"},
});
const answer = [
{__ROW_PATH__: [], x: 3},
{__ROW_PATH__: [false], x: 2},
{__ROW_PATH__: [true], x: 2},
];
table.update({
x: [5],
y: ["a"],
z: [true],
});
const result = await view.to_json();
expect(result).toEqual(answer);
view.delete();
table.delete();
});

it("['z'], first by index with partial updates", async function () {
var table = await perspective.table(data, {index: "y"});
var view = await table.view({
Expand Down

0 comments on commit 0c97a68

Please sign in to comment.