import './_planet.mjs';
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { clusterVents, ventText, zoomBucket } from '../js/vents.js';
const V = (lat, lon, type = 0) => ({ lat, lon, type, temp_c: 350, flow: 2, mineral: type });
test('far apart: one marker each; close together: one cluster with a count', () => {
const vents = [V(0, 0), V(0.01, 0.01), V(10, 10)];
const fine = clusterVents(vents, 0.01); // 40 px ≈ 0.4 km: nothing merges
assert.equal(fine.length, 3);
assert.ok(fine.every(c => c.n === 1 && c.v));
const coarse = clusterVents(vents, 10); // 40 px ≈ 400 km
assert.equal(coarse.length, 2);
const big = coarse.find(c => c.n === 2);
assert.ok(big && Math.abs(big.lat - 0.005) < 1e-9);
});
test('hover text names type, temperature and mineral', () => {
const t = ventText(V(0, 0, 0), ['black smoker', 'white smoker'], ['copper-iron sulfides', 'zinc sulfides and barite']);
assert.equal(t, 'black smoker · 350 °C · copper-iron sulfides · strong flow');
});
test('zoom buckets change every ×1.5', () => {
assert.equal(zoomBucket(1), zoomBucket(1.2));
assert.notEqual(zoomBucket(1), zoomBucket(1.6));
});