-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update runtime tests for refactored
point
selection type.
- Loading branch information
Showing
106 changed files
with
85 additions
and
127 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
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}`); | ||
} | ||
}); | ||
} | ||
}); |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Oops, something went wrong.