-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tables
delete
bug in perspective-workspace
- Loading branch information
Showing
3 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/perspective-workspace/test/js/unit/tables.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2018, the Perspective Authors. | ||
* | ||
* This file is part of the Perspective library, distributed under the terms of | ||
* the Apache License 2.0. The full license can be found in the LICENSE file. | ||
* | ||
*/ | ||
|
||
import {PerspectiveWorkspace} from "../../../src/js/workspace/workspace"; | ||
import perspective from "@finos/perspective"; | ||
|
||
describe("tables", () => { | ||
test("setting a table calls load on a subscribed viewer", () => { | ||
const table = perspective.table([{a: 1}]); | ||
const viewers = {One: {table: "test", name: "One"}}; | ||
const config = { | ||
viewers, | ||
detail: { | ||
main: { | ||
currentIndex: 0, | ||
type: "tab-area", | ||
widgets: ["One"] | ||
} | ||
} | ||
}; | ||
|
||
const workspace = new PerspectiveWorkspace(document.body); | ||
workspace.restore(config); | ||
|
||
const widget = workspace.getAllWidgets()[0]; | ||
expect(widget.viewer.load).not.toBeCalled(); | ||
|
||
workspace.tables.set("test", table); | ||
|
||
expect(widget.viewer.load).toBeCalled(); | ||
}); | ||
|
||
test("delete a table without subscribers works", () => { | ||
const table = perspective.table([{a: 1}]); | ||
const workspace = new PerspectiveWorkspace(document.body); | ||
|
||
workspace.tables.set("test", table); | ||
expect(workspace.tables.has("test")).toBeTruthy(); | ||
|
||
expect(workspace.tables.delete("test")).toBeTruthy(); | ||
expect(workspace.tables.has("test")).toBeFalsy(); | ||
}); | ||
|
||
test("delete a table with subscribers fails", () => { | ||
const table = perspective.table([{a: 1}]); | ||
const viewers = {One: {table: "test", name: "One"}}; | ||
const config = { | ||
viewers, | ||
detail: { | ||
main: { | ||
currentIndex: 0, | ||
type: "tab-area", | ||
widgets: ["One"] | ||
} | ||
} | ||
}; | ||
|
||
const workspace = new PerspectiveWorkspace(document.body); | ||
workspace.restore(config); | ||
workspace.tables.set("test", table); | ||
expect(workspace.tables.has("test")).toBeTruthy(); | ||
|
||
expect(workspace.tables.delete("test")).toBeFalsy(); | ||
expect(workspace.tables.has("test")).toBeTruthy(); | ||
}); | ||
}); |