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

Invalid filters #375

Merged
merged 15 commits into from
Jan 14, 2019
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
Added tests for is_valid_filter function
  • Loading branch information
Ro4052 committed Jan 10, 2019
commit ecb7d44bc341e3bdd243eaa597dd7cfb601799ee
67 changes: 67 additions & 0 deletions packages/perspective/test/js/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,72 @@ module.exports = perspective => {
table.delete();
});
});

describe("is_valid_filter", function() {
it("x == 2", async function() {
var table = perspective.table(data);
let isValid = await table.is_valid_filter(["x", "==", 2]);
expect(isValid).toBeTruthy();
table.delete();
});
it("x < null", async function() {
var table = perspective.table(data);
let isValid = await table.is_valid_filter(["x", "<", null]);
expect(isValid).toBeFalsy();
table.delete();
});
it("x > undefined", async function() {
var table = perspective.table(data);
let isValid = await table.is_valid_filter(["x", ">", undefined]);
expect(isValid).toBeFalsy();
table.delete();
});
it('x == ""', async function() {
var table = perspective.table(data);
let isValid = await table.is_valid_filter(["x", "==", ""]);
expect(isValid).toBeFalsy();
table.delete();
});
it("valid date", async function() {
const schema = {
x: "string",
y: "date"
};
var table = perspective.table(schema);
let isValid = await table.is_valid_filter(["y", "==", "01-01-1970"]);
expect(isValid).toBeTruthy();
table.delete();
});
it("invalid date", async function() {
const schema = {
x: "string",
y: "date"
};
var table = perspective.table(schema);
let isValid = await table.is_valid_filter(["y", "<", "1234"]);
expect(isValid).toBeFalsy();
table.delete();
});
it("valid datetime", async function() {
const schema = {
x: "string",
y: "datetime"
};
var table = perspective.table(schema);
let isValid = await table.is_valid_filter(["y", "==", "11:11:11.111"]);
expect(isValid).toBeTruthy();
table.delete();
});
it("invalid datetime", async function() {
const schema = {
x: "string",
y: "datetime"
};
var table = perspective.table(schema);
let isValid = await table.is_valid_filter(["y", ">", "11:11:11:111"]);
expect(isValid).toBeFalsy();
table.delete();
});
});
});
};