Skip to content

Commit

Permalink
update runtime tests for refactored point selection type.
Browse files Browse the repository at this point in the history
  • Loading branch information
arvind committed Oct 7, 2020
1 parent 93dfc97 commit c4aff1c
Show file tree
Hide file tree
Showing 106 changed files with 85 additions and 127 deletions.
161 changes: 80 additions & 81 deletions test-runtime/discrete.test.ts
Original file line number Diff line number Diff line change
@@ -1,98 +1,97 @@
import {Page} from 'puppeteer';
import {SELECTION_ID} from '../src/selection';
import {SelectionType, SELECTION_ID} from '../src/selection';
import {embedFn, fill, hits as hitsMaster, pt, spec, testRenderFn} from './util';

declare const page: Page;
for (const type of ['single', 'multi']) {
describe(`${type} selections at runtime in unit views`, () => {
beforeAll(async () => {
await page.goto('http://0.0.0.0:8000/test-runtime/');
});
describe(`point selections at runtime in unit views`, () => {
beforeAll(async () => {
await page.goto('http://0.0.0.0:8000/test-runtime/');
});

const type: SelectionType = 'point';
const hits = hitsMaster.discrete;
const embed = embedFn(page);
const testRender = testRenderFn(page, `${type}/unit`);

const hits = hitsMaster.discrete;
const embed = embedFn(page);
const testRender = testRenderFn(page, `${type}/unit`);
it('should add values to the store', async () => {
for (let i = 0; i < hits.qq.length; i++) {
await embed(spec('unit', i, {type}));
const store = await page.evaluate(pt('qq', i));
expect(store).toHaveLength(1);
expect(store[0].fields).toHaveLength(1);
expect(store[0].values).toHaveLength(1);
expect(store[0].fields[0].field).toEqual(SELECTION_ID);
expect(store[0].fields[0].type).toEqual('E');
await testRender(`click_${i}`);
}
});

it('should add values to the store', async () => {
it('should respect projections', async () => {
let values: number[][] = [];
let encodings: string[] = [];
let fields: string[] = [];
const t = async (emb: (i: number) => void) => {
for (let i = 0; i < hits.qq.length; i++) {
await embed(spec('unit', i, {type}));
emb(i);
const store = await page.evaluate(pt('qq', i));
expect(store).toHaveLength(1);
expect(store[0].fields).toHaveLength(1);
expect(store[0].values).toHaveLength(1);
expect(store[0].fields[0].field).toEqual(SELECTION_ID);
expect(store[0].fields[0].type).toEqual('E');
await testRender(`click_${i}`);
expect(store[0].fields).toHaveLength(fields.length);
expect(store[0].values).toHaveLength(fields.length);
expect(store[0].fields.map((f: any) => f.field)).toEqual(fields);
expect(store[0].fields.map((f: any) => f.type)).toEqual(fill('E', fields.length));
expect(store[0].values).toEqual(values[i]);
await testRender(`${encodings}_${fields}_${i}`);
}
});
};

it('should respect projections', async () => {
let values: number[][] = [];
let encodings: string[] = [];
let fields: string[] = [];
const t = async (emb: (i: number) => void) => {
for (let i = 0; i < hits.qq.length; i++) {
emb(i);
const store = await page.evaluate(pt('qq', i));
expect(store).toHaveLength(1);
expect(store[0].fields).toHaveLength(fields.length);
expect(store[0].values).toHaveLength(fields.length);
expect(store[0].fields.map((f: any) => f.field)).toEqual(fields);
expect(store[0].fields.map((f: any) => f.type)).toEqual(fill('E', fields.length));
expect(store[0].values).toEqual(values[i]);
await testRender(`${encodings}_${fields}_${i}`);
}
};
encodings = ['x', 'color'];
fields = ['a', 'c'];
values = [
[2, 1],
[6, 0]
];
await t(async (i: number) => await embed(spec('unit', i, {type, encodings})));

encodings = ['x', 'color'];
fields = ['a', 'c'];
values = [
[2, 1],
[6, 0]
];
await t(async (i: number) => await embed(spec('unit', i, {type, encodings})));

encodings = [];
fields = ['c', 'a', 'b'];
values = [
[1, 2, 53],
[0, 6, 87]
];
await t(async (i: number) => await embed(spec('unit', i, {type, fields})));
});
encodings = [];
fields = ['c', 'a', 'b'];
values = [
[1, 2, 53],
[0, 6, 87]
];
await t(async (i: number) => await embed(spec('unit', i, {type, fields})));
});

it('should clear out the store', async () => {
for (let i = 0; i < hits.qq_clear.length; i++) {
await embed(spec('unit', i, {type}));
let store = await page.evaluate(pt('qq', i));
expect(store).toHaveLength(1);
it('should clear out the store', async () => {
for (let i = 0; i < hits.qq_clear.length; i++) {
await embed(spec('unit', i, {type}));
let store = await page.evaluate(pt('qq', i));
expect(store).toHaveLength(1);

store = await page.evaluate(pt('qq_clear', i));
expect(store).toHaveLength(0);
await testRender(`clear_${i}`);
}
});
store = await page.evaluate(pt('qq_clear', i));
expect(store).toHaveLength(0);
await testRender(`clear_${i}`);
}
});

it('should support selecting bins', async () => {
const encodings = ['x', 'color', 'y'];
const fields = ['a', 'c', 'b'];
const types = ['R-RE', 'E', 'R-RE'];
const values = [
[[1, 2], 0, [40, 50]],
[[8, 9], 1, [10, 20]]
];
it('should support selecting bins', async () => {
const encodings = ['x', 'color', 'y'];
const fields = ['a', 'c', 'b'];
const types = ['R-RE', 'E', 'R-RE'];
const values = [
[[1, 2], 0, [40, 50]],
[[8, 9], 1, [10, 20]]
];

for (let i = 0; i < hits.bins.length; i++) {
await embed(spec('unit', i, {type, encodings}, {x: {bin: true}, y: {bin: true}}));
const store = await page.evaluate(pt('bins', i));
expect(store).toHaveLength(1);
expect(store[0].fields).toHaveLength(fields.length);
expect(store[0].values).toHaveLength(fields.length);
expect(store[0].fields.map((f: any) => f.field)).toEqual(fields);
expect(store[0].fields.map((f: any) => f.type)).toEqual(types);
expect(store[0].values).toEqual(values[i]);
await testRender(`bins_${i}`);
}
});
for (let i = 0; i < hits.bins.length; i++) {
await embed(spec('unit', i, {type, encodings}, {x: {bin: true}, y: {bin: true}}));
const store = await page.evaluate(pt('bins', i));
expect(store).toHaveLength(1);
expect(store[0].fields).toHaveLength(fields.length);
expect(store[0].values).toHaveLength(fields.length);
expect(store[0].fields.map((f: any) => f.field)).toEqual(fields);
expect(store[0].fields.map((f: any) => f.type)).toEqual(types);
expect(store[0].values).toEqual(values[i]);
await testRender(`bins_${i}`);
}
});
}
});
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/global_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/global_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/global_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/global_clear_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/intersect_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/intersect_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/intersect_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/intersect_clear_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/intersect_clear_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/intersect_clear_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/union_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/union_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/union_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/union_clear_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/union_clear_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/facet/union_clear_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/global_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/global_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/global_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/global_clear_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/intersect_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/intersect_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/intersect_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/intersect_clear_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/intersect_clear_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/intersect_clear_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/union_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/union_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/union_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/union_clear_0.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/union_clear_1.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/repeat/union_clear_2.svg
Diff not rendered.
1 change: 0 additions & 1 deletion test-runtime/resources/single/unit/_c,a,b_0.svg
Diff not rendered.
Loading

0 comments on commit c4aff1c

Please sign in to comment.