App_test.res.mjs

  1// Generated by ReScript, PLEASE EDIT WITH CARE
  2
  3import * as State from "../src/State.res.mjs";
  4import * as Vitest from "vitest";
  5
  6Vitest.describe("Waypoint markers", () => {
  7  Vitest.test("waypoints are extracted correctly from signal", async t => {
  8    let testWaypoint_point = [
  9      85.324,
 10      27.717
 11    ];
 12    let testWaypoint_cons = [];
 13    let testWaypoint = {
 14      id: "wp1",
 15      point: testWaypoint_point,
 16      from: undefined,
 17      label: "Kathmandu",
 18      gid: "kathmandu_gid",
 19      country: "NP",
 20      cons: testWaypoint_cons,
 21      nonroutable: false,
 22      error: undefined
 23    };
 24    let signal = State.getOrCreateWaypointsSignal("test-doc");
 25    signal.value = [testWaypoint];
 26    let waypoints = signal.value;
 27    t.expect(waypoints.length).toEqual(1);
 28    let wp = waypoints[0];
 29    if (wp !== undefined) {
 30      t.expect(wp.id).toEqual("wp1");
 31      t.expect(wp.point).toEqual([
 32        85.324,
 33        27.717
 34      ]);
 35      t.expect(wp.label).toEqual("Kathmandu");
 36    } else {
 37      t.expect("waypoint should exist").toEqual("");
 38    }
 39  });
 40  Vitest.test("empty waypoints signal returns empty array", async t => {
 41    let signal = State.getOrCreateWaypointsSignal("empty-doc");
 42    let waypoints = signal.value;
 43    t.expect(waypoints.length).toEqual(0);
 44  });
 45  Vitest.test("waypoints signal updates when set", async t => {
 46    let signal = State.getOrCreateWaypointsSignal("update-doc");
 47    t.expect(signal.value.length).toEqual(0);
 48    let wp1_point = [
 49      85.0,
 50      27.0
 51    ];
 52    let wp1_cons = [];
 53    let wp1 = {
 54      id: "wp1",
 55      point: wp1_point,
 56      from: undefined,
 57      label: "Point 1",
 58      gid: "gid1",
 59      country: "NP",
 60      cons: wp1_cons,
 61      nonroutable: false,
 62      error: undefined
 63    };
 64    let wp2_point = [
 65      83.0,
 66      28.0
 67    ];
 68    let wp2_cons = [];
 69    let wp2 = {
 70      id: "wp2",
 71      point: wp2_point,
 72      from: undefined,
 73      label: "Point 2",
 74      gid: "gid2",
 75      country: "NP",
 76      cons: wp2_cons,
 77      nonroutable: false,
 78      error: undefined
 79    };
 80    signal.value = [
 81      wp1,
 82      wp2
 83    ];
 84    t.expect(signal.value.length).toEqual(2);
 85    signal.value = [wp1];
 86    t.expect(signal.value.length).toEqual(1);
 87  });
 88  Vitest.test("waypoint coordinates are in lon-lat order", async t => {
 89    let testWaypoint_point = [
 90      85.324,
 91      27.717
 92    ];
 93    let testWaypoint_cons = [];
 94    let testWaypoint = {
 95      id: "coord-test",
 96      point: testWaypoint_point,
 97      from: undefined,
 98      label: "Test",
 99      gid: "test_gid",
100      country: "NP",
101      cons: testWaypoint_cons,
102      nonroutable: false,
103      error: undefined
104    };
105    let signal = State.getOrCreateWaypointsSignal("coord-doc");
106    signal.value = [testWaypoint];
107    let waypoints = signal.value;
108    let wp = waypoints[0];
109    if (wp !== undefined) {
110      let match = wp.point;
111      t.expect(match[0]).toEqual(85.324);
112      t.expect(match[1]).toEqual(27.717);
113      return;
114    }
115    t.expect("waypoint should exist").toEqual("");
116  });
117});
118
119/*  Not a pure module */