feat: link transit registration to boxing
This commit is contained in:
85
test/services/registration_linking_test.dart
Normal file
85
test/services/registration_linking_test.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pad_scanner/services/code_parser.dart';
|
||||
import 'package:pad_scanner/services/registration_linking.dart';
|
||||
|
||||
void main() {
|
||||
group('registration linking helpers', () {
|
||||
test('detects transit target by type or code prefix', () {
|
||||
expect(isTransitTarget(CodeType.locationTransit, 'TRANS-01'), isTrue);
|
||||
expect(isTransitTarget(CodeType.locationNormal, 'TRANS-02'), isTrue);
|
||||
expect(isTransitTarget(CodeType.locationNormal, 'A01-02-03'), isFalse);
|
||||
expect(isTransitTarget(null, null), isFalse);
|
||||
});
|
||||
|
||||
test('builds submit labels for normal and transit modes', () {
|
||||
expect(
|
||||
registrationSubmitLabel(
|
||||
isTransitTarget: false,
|
||||
isLocked: false,
|
||||
zongpaiCount: 1,
|
||||
),
|
||||
'确 认 上 架',
|
||||
);
|
||||
expect(
|
||||
registrationSubmitLabel(
|
||||
isTransitTarget: false,
|
||||
isLocked: true,
|
||||
zongpaiCount: 3,
|
||||
),
|
||||
'批量上架(3 条)',
|
||||
);
|
||||
expect(
|
||||
registrationSubmitLabel(
|
||||
isTransitTarget: true,
|
||||
isLocked: false,
|
||||
zongpaiCount: 1,
|
||||
),
|
||||
'转运并装箱',
|
||||
);
|
||||
expect(
|
||||
registrationSubmitLabel(
|
||||
isTransitTarget: true,
|
||||
isLocked: true,
|
||||
zongpaiCount: 3,
|
||||
),
|
||||
'批量转运并凑箱(3 条)',
|
||||
);
|
||||
});
|
||||
|
||||
test('uses orange submit color only for enabled transit target', () {
|
||||
const primary = Colors.blue;
|
||||
expect(
|
||||
registrationSubmitColor(
|
||||
canSubmit: true,
|
||||
isTransitTarget: true,
|
||||
primaryColor: primary,
|
||||
),
|
||||
Colors.orange,
|
||||
);
|
||||
expect(
|
||||
registrationSubmitColor(
|
||||
canSubmit: true,
|
||||
isTransitTarget: false,
|
||||
primaryColor: primary,
|
||||
),
|
||||
primary,
|
||||
);
|
||||
expect(
|
||||
registrationSubmitColor(
|
||||
canSubmit: false,
|
||||
isTransitTarget: true,
|
||||
primaryColor: primary,
|
||||
),
|
||||
Colors.grey.shade300,
|
||||
);
|
||||
});
|
||||
|
||||
test('validates all codes belong to one paicha', () {
|
||||
expect(allSamePaicha(['R00001', 'R00001']), isTrue);
|
||||
expect(allSamePaicha(['R00001', 'R00002']), isFalse);
|
||||
expect(allSamePaicha(['R00001', null]), isFalse);
|
||||
expect(allSamePaicha(<String>[]), isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user