This commit is contained in:
@ -52,6 +52,55 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('WatchAlertEnvelope', () {
|
||||
test('round-trips every alert kind through JSON', () {
|
||||
for (final kind in WatchAlertKind.values) {
|
||||
final alert = WatchAlertEnvelope(
|
||||
alertId: 'alert-${kind.name}',
|
||||
sessionId: 'session-1',
|
||||
revision: 7,
|
||||
kind: kind,
|
||||
timerKind: WatchTimerKind.step,
|
||||
programIndex: 0,
|
||||
exerciseIndex: 1,
|
||||
setIndex: 2,
|
||||
passageIndex: 3,
|
||||
stepIndex: 4,
|
||||
scheduledForEpochMs: 1710000000700,
|
||||
expiresAtEpochMs: 1710000002700,
|
||||
pattern: kind == WatchAlertKind.countdownTick
|
||||
? WatchAlertPattern.countdownTick
|
||||
: WatchAlertPattern.timerFinished,
|
||||
);
|
||||
|
||||
final decoded = WatchAlertEnvelope.fromJson(
|
||||
jsonDecode(jsonEncode(alert.toJson())) as Map<String, Object?>,
|
||||
);
|
||||
|
||||
expect(decoded, alert);
|
||||
}
|
||||
});
|
||||
|
||||
test('falls back safely for absent fields', () {
|
||||
final alert = WatchAlertEnvelope.fromJson({});
|
||||
|
||||
expect(alert.schemaVersion, watchBridgeSchemaVersion);
|
||||
expect(alert.alertId, '');
|
||||
expect(alert.sessionId, '');
|
||||
expect(alert.revision, 0);
|
||||
expect(alert.kind, WatchAlertKind.countdownTick);
|
||||
expect(alert.timerKind, WatchTimerKind.step);
|
||||
expect(alert.programIndex, isNull);
|
||||
expect(alert.exerciseIndex, isNull);
|
||||
expect(alert.setIndex, isNull);
|
||||
expect(alert.passageIndex, isNull);
|
||||
expect(alert.stepIndex, isNull);
|
||||
expect(alert.scheduledForEpochMs, 0);
|
||||
expect(alert.expiresAtEpochMs, 0);
|
||||
expect(alert.pattern, WatchAlertPattern.countdownTick);
|
||||
});
|
||||
});
|
||||
|
||||
group('WatchSensorSummary', () {
|
||||
test('round-trips heart rate summary through JSON', () {
|
||||
const summary = WatchSensorSummary(
|
||||
|
||||
Reference in New Issue
Block a user