Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

817 B
Raw Blame
import test from 'node:test';
import assert from 'node:assert/strict';
import { normalizeRegionalWeather, weatherCodeLabel } from './regionalModel.js';
test('missing weather observations never assert clear conditions', () => {
  for (const value of [null, undefined, '', ' ', false, true]) {
    assert.equal(weatherCodeLabel(value), 'CONDITIONS UNKNOWN');
    assert.equal(
      normalizeRegionalWeather({ current: { temperature_2m: value } }),
      null,
    );
  }
  assert.equal(weatherCodeLabel(0), 'CLEAR');
  assert.equal(weatherCodeLabel('0'), 'CLEAR');
  const record = normalizeRegionalWeather({
    current: { temperature_2m: 0, weather_code: null, wind_speed_10m: false },
  });
  assert.equal(record.temperatureC, 0);
  assert.equal(record.weatherCode, null);
  assert.equal(record.windKph, null);
});