No content changes: git diff --ignore-all-space over these files is empty. The churn came from editing on Windows against a repo checked out with LF.
57 lines
1.8 KiB
Dart
57 lines
1.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:app_pfm_ocr_v2/features/documents/poll_outcome.dart';
|
|
import 'package:app_pfm_ocr_v2/models/document_model.dart';
|
|
|
|
DocumentModel _doc({String? parseStatus, bool parsed = false}) {
|
|
return DocumentModel(
|
|
id: '1',
|
|
tanggal: '',
|
|
noPo: '',
|
|
noSo: '',
|
|
noDo: '',
|
|
kepadaYth: '',
|
|
orderUntuk: '',
|
|
alamat: '',
|
|
platTruk: '',
|
|
namaDriver: '',
|
|
namaPenerima: '',
|
|
items: const [],
|
|
createdAt: DateTime(2026, 7, 10),
|
|
parsed: parsed,
|
|
parseStatus: parseStatus,
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
group('resolvePollOutcome', () {
|
|
test('parseStatus done -> PollOutcomeKind.done carrying the fetched document', () {
|
|
final doc = _doc(parseStatus: 'done', parsed: true);
|
|
final outcome = resolvePollOutcome(doc);
|
|
expect(outcome.kind, PollOutcomeKind.done);
|
|
expect(outcome.document, doc);
|
|
expect(outcome.message, isNull);
|
|
});
|
|
|
|
test('parseStatus failed -> PollOutcomeKind.failed with an explicit message', () {
|
|
final doc = _doc(parseStatus: 'failed');
|
|
final outcome = resolvePollOutcome(doc);
|
|
expect(outcome.kind, PollOutcomeKind.failed);
|
|
expect(outcome.document, isNull);
|
|
expect(outcome.message, isNotNull);
|
|
});
|
|
|
|
test('parseStatus pending -> PollOutcomeKind.pending, keep polling', () {
|
|
final doc = _doc(parseStatus: 'pending');
|
|
final outcome = resolvePollOutcome(doc);
|
|
expect(outcome.kind, PollOutcomeKind.pending);
|
|
expect(outcome.document, isNull);
|
|
});
|
|
|
|
test('missing/unknown parseStatus (legacy response) is treated as pending, not failed', () {
|
|
final doc = _doc(parseStatus: null);
|
|
final outcome = resolvePollOutcome(doc);
|
|
expect(outcome.kind, PollOutcomeKind.pending);
|
|
});
|
|
});
|
|
}
|