* Adopt type=module follow changes in d3-format: * type=module * add exports * remove zip * license: ISC * update dependencies * es6 rather than no-undef * remove Sublime project * add eslint.json * related d3/d3#3502; extract copyrights from LICENSE * update dependencies * stricter eslint * cleaner imports * Update README Co-authored-by: Mike Bostock <mbostock@gmail.com>
20 lines
664 B
JavaScript
20 lines
664 B
JavaScript
import assert from "assert";
|
|
import {forceSimulation} from "../src/index.js";
|
|
|
|
it("simulation.find finds a node", () => {
|
|
const f = forceSimulation().stop();
|
|
const a = {x: 5, y: 0}, b = {x: 10, y: 16}, c = {x: -10, y: -4};
|
|
f.nodes([a, b, c]);
|
|
assert.strictEqual(f.find(0, 0), a);
|
|
assert.strictEqual(f.find(0, 20), b);
|
|
});
|
|
|
|
it("simulation.find(x, y, radius) finds a node within radius", () => {
|
|
const f = forceSimulation().stop();
|
|
const a = {x: 5, y: 0}, b = {x: 10, y: 16}, c = {x: -10, y: -4};
|
|
f.nodes([a, b, c]);
|
|
assert.strictEqual(f.find(0, 0), a);
|
|
assert.strictEqual(f.find(0, 0, 1), undefined);
|
|
assert.strictEqual(f.find(0, 20), b);
|
|
});
|