fix:对齐金值的报名验证,商城入口逻辑对齐
This commit is contained in:
1 parent
3b089e2205
commit
7b1852d9a6
20 files changed
+682
-116
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:jinzhi_flutter_app/features/mall/application/mall_tab_config.dart';
|
||||
|
||||
@@ -41,4 +43,69 @@ void main() {
|
||||
expect(nativeApp.opensInApp, isFalse);
|
||||
expect(external.opensInApp, isFalse);
|
||||
});
|
||||
|
||||
test('shows the first-install promo only for a configured mall entry', () {
|
||||
const configured = MallTabConfig(
|
||||
enabled: true,
|
||||
url: 'https://mall.example.com',
|
||||
entryPromoEnabled: true,
|
||||
entryBadgeText: '新人礼',
|
||||
entryTipTitle: '新人礼:¥360 铂金订购券',
|
||||
entryTipBody: '点击这里进商城',
|
||||
);
|
||||
const disabled = MallTabConfig(
|
||||
enabled: true,
|
||||
url: 'https://mall.example.com',
|
||||
entryPromoEnabled: false,
|
||||
entryTipTitle: '新人礼',
|
||||
);
|
||||
|
||||
expect(configured.showsEntryBadge, isTrue);
|
||||
expect(configured.showsEntryTip, isTrue);
|
||||
expect(disabled.showsEntryBadge, isFalse);
|
||||
expect(disabled.showsEntryTip, isFalse);
|
||||
});
|
||||
|
||||
test('parses the server-provided mall entry promotion fields', () {
|
||||
final creative = <int>[
|
||||
..._stringField(9, 'https://mall.example.com'),
|
||||
..._boolField(16, true),
|
||||
..._stringField(17, '新人礼'),
|
||||
..._stringField(18, '新人礼:¥360 铂金订购券'),
|
||||
..._stringField(19, '点击这里进商城'),
|
||||
];
|
||||
final config = parseMallTabConfigResponse(<int>[
|
||||
..._boolField(1, true),
|
||||
..._bytesField(2, creative),
|
||||
]);
|
||||
|
||||
expect(config.showsEntryBadge, isTrue);
|
||||
expect(config.entryBadgeText, '新人礼');
|
||||
expect(config.entryTipTitle, '新人礼:¥360 铂金订购券');
|
||||
expect(config.entryTipBody, '点击这里进商城');
|
||||
});
|
||||
}
|
||||
|
||||
List<int> _stringField(int tag, String value) =>
|
||||
_bytesField(tag, utf8.encode(value));
|
||||
|
||||
List<int> _bytesField(int tag, List<int> value) => <int>[
|
||||
..._varint((tag << 3) | 2),
|
||||
..._varint(value.length),
|
||||
...value,
|
||||
];
|
||||
|
||||
List<int> _boolField(int tag, bool value) => <int>[
|
||||
..._varint(tag << 3),
|
||||
value ? 1 : 0,
|
||||
];
|
||||
|
||||
List<int> _varint(int value) {
|
||||
final bytes = <int>[];
|
||||
while (value > 127) {
|
||||
bytes.add((value & 127) | 128);
|
||||
value >>= 7;
|
||||
}
|
||||
bytes.add(value);
|
||||
return bytes;
|
||||
}
|
||||
Reference in new issue
Block a user