Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix autocomplete error when filtering string column w/null values
* Factor out a function for filtering out null values before feeding them into the autocomplete choices * Add unit testing config to perspective-viewer package * Add a unit test to cover this bugfix
- Loading branch information
Showing
9 changed files
with
112 additions
and
15 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2017, 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. | ||
* | ||
*/ | ||
|
||
global.CustomEvent = () => {}; | ||
global.customElements = {define: () => {}}; | ||
global.HTMLElement = class { | ||
getAttribute() {} | ||
hasAttribute() {} | ||
removeAttribute() {} | ||
setAttribute() {} | ||
}; |
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,20 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2017, 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. | ||
* | ||
*/ | ||
|
||
module.exports = { | ||
roots: ["unit"], | ||
verbose: true, | ||
testURL: "http://localhost/", | ||
automock: false, | ||
transform: { | ||
".js$": "./transform.js", | ||
".html$": "html-loader-jest" | ||
}, | ||
setupFiles: ["./beforeEachSpec.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,13 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2017, 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. | ||
* | ||
*/ | ||
|
||
const config = require("../../babel.config.js"); | ||
config.presets[0][1].modules = "auto"; | ||
|
||
module.exports = require("babel-jest").createTransformer(config); |
35 changes: 35 additions & 0 deletions
35
packages/perspective-viewer/test/js/unit/dom_element.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,35 @@ | ||
/****************************************************************************** | ||
* | ||
* 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 {DomElement} from "../../../src/js/viewer/dom_element"; | ||
|
||
jest.mock("../../../src/less/computed_column.less", () => jest.fn()); | ||
|
||
describe(DomElement, () => { | ||
describe("._autocomplete_choices", () => { | ||
let dom_element, json_choices; | ||
|
||
beforeEach(() => { | ||
dom_element = new DomElement(); | ||
json_choices = [ | ||
{__ROW_PATH__: [], foo: 2}, | ||
{__ROW_PATH__: [null], foo: 25}, | ||
{__ROW_PATH__: ["somestring"], foo: 3}, | ||
{__ROW_PATH__: ["otherstring"], foo: 3} | ||
]; | ||
}); | ||
|
||
test("the first value and null values are filtered out", () => { | ||
expect(dom_element._autocomplete_choices(json_choices)).toEqual([ | ||
["somestring"], | ||
["otherstring"] | ||
]); | ||
}); | ||
}); | ||
}); |