From 0c97a682f46d058c18b5e902db2ffd40add7e2fa Mon Sep 17 00:00:00 2001 From: Andrew Stein Date: Sun, 6 Mar 2022 16:04:48 -0500 Subject: [PATCH] Add tests --- .gitignore | 4 -- packages/perspective/test/js/pivots.js | 62 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4d94e088d3..4ed4abdc1e 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/packages/perspective/test/js/pivots.js b/packages/perspective/test/js/pivots.js index b4e4206938..ce44d2787c 100644 --- a/packages/perspective/test/js/pivots.js +++ b/packages/perspective/test/js/pivots.js @@ -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({