52 lines
3.0 KiB
JavaScript
52 lines
3.0 KiB
JavaScript
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
|
|
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
|
|
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
|
|
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
|
|
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
|
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
|
|
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
|
|
// ┃ This file is part of the Perspective library, distributed under the terms ┃
|
|
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
|
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
|
|
import { test, expect } from "@perspective-dev/test";
|
|
import * as path from "node:path";
|
|
import { host } from "../../src/js/index.js";
|
|
import * as url from "url";
|
|
|
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url)).slice(0, -1);
|
|
|
|
test.describe("CLI", function () {
|
|
let server, port;
|
|
test.beforeAll(async () => {
|
|
const options = { port: 0 };
|
|
server = await host(path.join(__dirname, "../csv/test.csv"), options);
|
|
port = server._server.address().port;
|
|
});
|
|
|
|
test.afterAll(async (options) => {
|
|
await server.close();
|
|
});
|
|
|
|
test("Tests something", async ({ page }) => {
|
|
await page.goto(`http://localhost:${port}/`);
|
|
await page.waitForSelector(
|
|
"perspective-viewer perspective-viewer-datagrid",
|
|
);
|
|
|
|
const json = await page.evaluate(async function () {
|
|
const viewer = document.querySelector("perspective-viewer");
|
|
await viewer.flush();
|
|
const view = await viewer.getView();
|
|
return await view.to_json();
|
|
});
|
|
|
|
expect(json).toEqual([
|
|
{ x: 1, y: 2 },
|
|
{ x: 3, y: 4 },
|
|
{ x: 5, y: 6 },
|
|
]);
|
|
});
|
|
});
|