import { describe, expect, it } from "vitest";

import { getDeviceID } from "../src/deviceid";
import { Frame } from "../src/frame";

describe("DeviceID parsing", () => {
  it("parses known device ID from tocall", () => {
    const data = "WB2OSZ-5>APDW17:!4237.14NS07120.83W#PHG7140";
    const frame = Frame.fromString(data);
    const deviceID = getDeviceID(frame.destination);
    expect(deviceID).not.toBeNull();
    expect(deviceID?.tocall).toBe("APDW??");
    expect(deviceID?.vendor).toBe("WB2OSZ");
  });

  it("returns null for unknown device ID", () => {
    const data = "CALL>WORLD:!4237.14NS07120.83W#PHG7140";
    const frame = Frame.fromString(data);
    const deviceID = getDeviceID(frame.destination);
    expect(deviceID).toBeNull();
  });
});
