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

Fix update bugs #749

Merged
merged 2 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
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
Next Next commit
fix off-by-one in dispatch.unsubscribe, remove .only from test suite
  • Loading branch information
sc1f committed Oct 2, 2019
commit 31d21c76480c80f0c214f7a328f4d5cb22c93d77
3 changes: 2 additions & 1 deletion packages/perspective/src/js/api/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export function subscribe(method, cmd) {
resolve = args.splice(i, 1)[0];
}
}
__CALLBACK_CACHE__.set(resolve, __CALLBACK_INDEX__++);
__CALLBACK_INDEX__++;
__CALLBACK_CACHE__.set(resolve, __CALLBACK_INDEX__);
let msg = {
cmd: cmd || "view_method",
name: this._name,
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective/test/js/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

module.exports = perspective => {
describe.only("Delete", function() {
describe("Delete", function() {
it("calls all delete callbacks registered on table", async function() {
const table = perspective.table([{x: 1}]);

Expand Down
44 changes: 44 additions & 0 deletions packages/perspective/test/js/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,4 +1290,48 @@ module.exports = perspective => {
table.delete();
});
});

describe("Remove update", function() {
it("Should remove a single update", function(done) {
const cb1 = jest.fn();
const cb2 = () => {
expect(cb1).toBeCalledTimes(0);
setTimeout(() => {
view.delete();
table.delete();
done();
}, 0);
};
const table = perspective.table(meta);
const view = table.view();
view.on_update(cb1);
view.on_update(cb2);
view.remove_update(cb1);
table.update(data);
});

it("Should remove multiple updates", function(done) {
const cb1 = jest.fn();
const cb2 = jest.fn();
const cb3 = function() {
// cb2 should have been called
expect(cb1).toBeCalledTimes(0);
expect(cb2).toBeCalledTimes(0);
setTimeout(() => {
view.delete();
table.delete();
done();
}, 0);
};

const table = perspective.table(meta);
const view = table.view();
view.on_update(cb1);
view.on_update(cb2);
view.on_update(cb3);
view.remove_update(cb1);
view.remove_update(cb2);
table.update(data);
});
});
};