Implemented Query, Telemetry, Weather and RawGPS parsing
This commit is contained in:
37
test/frame.weather.test.ts
Normal file
37
test/frame.weather.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { Frame } from "../src/frame";
|
||||
import { WeatherPayload } from "../src/frame.types";
|
||||
import { Dissected } from "@hamradio/packet";
|
||||
|
||||
describe("Frame decode - Weather", () => {
|
||||
it("parses weather with timestamp, wind, temp, rain, humidity and pressure", () => {
|
||||
const data = "SRC>DEST:_120345z180/10g15t072r000p025P050h50b10132";
|
||||
const frame = Frame.fromString(data);
|
||||
const payload = frame.decode() as WeatherPayload;
|
||||
expect(payload).not.toBeNull();
|
||||
expect(payload.type).toBe("weather");
|
||||
expect(payload.timestamp).toBeDefined();
|
||||
expect(payload.windDirection).toBe(180);
|
||||
expect(payload.windSpeed).toBe(10);
|
||||
expect(payload.windGust).toBe(15);
|
||||
expect(payload.temperature).toBe(72);
|
||||
expect(payload.rainLast24Hours).toBe(25);
|
||||
expect(payload.rainSinceMidnight).toBe(50);
|
||||
expect(payload.humidity).toBe(50);
|
||||
expect(payload.pressure).toBe(10132);
|
||||
});
|
||||
|
||||
it("emits structure when requested", () => {
|
||||
const data = "SRC>DEST:_120345z180/10g15t072r000p025P050h50b10132";
|
||||
const frame = Frame.fromString(data);
|
||||
const res = frame.decode(true) as {
|
||||
payload: WeatherPayload;
|
||||
structure: Dissected;
|
||||
};
|
||||
expect(res.payload).not.toBeNull();
|
||||
expect(Array.isArray(res.structure)).toBe(true);
|
||||
const names = res.structure.map((s) => s.name);
|
||||
expect(names).toContain("timestamp");
|
||||
expect(names).toContain("weather");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user