feat: add ScanRecord model with toJson

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-05-07 19:53:48 +08:00
parent 366e56710c
commit 2693c13133
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pad_scanner/models/scan_record.dart';
void main() {
group('ScanRecord', () {
test('creates with correct defaults', () {
final record = ScanRecord(
barcode: '1234567890',
codeType: 'CODE128',
timestamp: DateTime.parse('2026-05-07T10:30:00Z'),
);
expect(record.barcode, '1234567890');
expect(record.codeType, 'CODE128');
expect(record.status, SendStatus.pending);
});
test('toJson produces correct map', () {
final record = ScanRecord(
barcode: 'ABC123',
codeType: 'QR',
timestamp: DateTime.parse('2026-05-07T10:30:00Z'),
);
final json = record.toJson();
expect(json['barcode'], 'ABC123');
expect(json['code_type'], 'QR');
expect(json['timestamp'], '2026-05-07T10:30:00.000Z');
});
});
}