Implemented Query, Telemetry, Weather and RawGPS parsing
This commit is contained in:
39
test/frame.query.test.ts
Normal file
39
test/frame.query.test.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { expect } from "vitest";
|
||||
import { describe, it } from "vitest";
|
||||
import { Dissected } from "@hamradio/packet";
|
||||
import { Frame } from "../src/frame";
|
||||
import { QueryPayload } from "../src/frame.types";
|
||||
|
||||
describe("Frame decode - Query", () => {
|
||||
it("decodes simple query without target", () => {
|
||||
const frame = Frame.fromString("SRC>DEST:?APRS");
|
||||
const payload = frame.decode() as QueryPayload;
|
||||
expect(payload).not.toBeNull();
|
||||
expect(payload.type).toBe("query");
|
||||
expect(payload.queryType).toBe("APRS");
|
||||
expect(payload.target).toBeUndefined();
|
||||
});
|
||||
|
||||
it("decodes query with target", () => {
|
||||
const frame = Frame.fromString("SRC>DEST:?PING N0CALL");
|
||||
const payload = frame.decode() as QueryPayload;
|
||||
expect(payload).not.toBeNull();
|
||||
expect(payload.type).toBe("query");
|
||||
expect(payload.queryType).toBe("PING");
|
||||
expect(payload.target).toBe("N0CALL");
|
||||
});
|
||||
|
||||
it("returns structure sections when requested", () => {
|
||||
const frame = Frame.fromString("SRC>DEST:?PING N0CALL");
|
||||
const result = frame.decode(true) as {
|
||||
payload: QueryPayload;
|
||||
structure: Dissected;
|
||||
};
|
||||
expect(result).toHaveProperty("payload");
|
||||
expect(result.payload.type).toBe("query");
|
||||
expect(Array.isArray(result.structure)).toBe(true);
|
||||
const names = result.structure.map((s) => s.name);
|
||||
expect(names).toContain("query type");
|
||||
expect(names).toContain("query target");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user