Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1159 - deltas are now generated on first update for 0-sided contexts #1164

Merged
merged 7 commits into from
Aug 26, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add JS tests
  • Loading branch information
sc1f committed Aug 24, 2020
commit 70d1994285e53db8959a37f0ad4fa6e228e88f91
108 changes: 108 additions & 0 deletions packages/perspective/test/js/delta.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,38 @@ module.exports = perspective => {
table.update(partial_change_y);
});

it("returns changed rows from schema", async function(done) {
let table = perspective.table(
{
x: "integer",
y: "string",
z: "boolean"
},
{index: "x"}
);
let view = table.view();
view.on_update(
async function(updated) {
const expected = [
{x: 1, y: "d", z: false},
{x: 2, y: "b", z: false},
{x: 3, y: "c", z: true}
];
await match_delta(perspective, updated.delta, expected);
view.delete();
table.delete();
done();
},
{mode: "row"}
);
table.update([
{x: 1, y: "a", z: true},
{x: 2, y: "b", z: false},
{x: 3, y: "c", z: true},
{x: 1, y: "d", z: false}
]);
});

it("returns added rows", async function(done) {
let table = perspective.table(data);
let view = table.view();
Expand All @@ -119,6 +151,25 @@ module.exports = perspective => {
table.update(partial_change_y);
});

it("returns added rows from schema", async function(done) {
let table = perspective.table({
x: "integer",
y: "string",
z: "boolean"
});
let view = table.view();
view.on_update(
async function(updated) {
await match_delta(perspective, updated.delta, data);
view.delete();
table.delete();
done();
},
{mode: "row"}
);
table.update(data);
});

it("returns deleted columns", async function(done) {
let table = perspective.table(data, {index: "x"});
let view = table.view();
Expand Down Expand Up @@ -162,6 +213,63 @@ module.exports = perspective => {
table.update(partial_change_y);
});

it("returns changed rows in sorted context from schema", async function(done) {
let table = perspective.table(
{
x: "integer",
y: "string",
z: "boolean"
},
{index: "x"}
);
let view = table.view({
sort: [["x", "desc"]]
});
view.on_update(
async function(updated) {
const expected = [
{x: 4, y: "a", z: true},
{x: 3, y: "c", z: true},
{x: 2, y: "b", z: false},
{x: 1, y: "d", z: false}
];
await match_delta(perspective, updated.delta, expected);
view.delete();
table.delete();
done();
},
{mode: "row"}
);
table.update([
{x: 1, y: "a", z: true},
{x: 2, y: "b", z: false},
{x: 3, y: "c", z: true},
{x: 1, y: "d", z: false},
{x: 4, y: "a", z: true}
]);
});

it("returns added rows in filtered context from schema", async function(done) {
let table = perspective.table({
x: "integer",
y: "string",
z: "boolean"
});
let view = table.view({
filter: [["x", ">", 3]]
});
view.on_update(
async function(updated) {
await match_delta(perspective, updated.delta, [{x: 4, y: "d", z: false}]);
view.delete();
table.delete();
done();
},
{mode: "row"}
);
table.update(data);
});

it("returns changed rows in non-sequential update", async function(done) {
let table = perspective.table(data, {index: "x"});
let view = table.view();
Expand Down