63 lines
2.1 KiB
Dart
63 lines
2.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:yumi/modules/room_game/bridge/hotgame_js_bridge.dart';
|
|
import 'package:yumi/modules/room_game/data/models/room_game_models.dart';
|
|
|
|
void main() {
|
|
test('normalizes documented hotgame recharge and quit bridge actions', () {
|
|
expect(HotgameBridgeActions.normalize('recharge'), 'recharge');
|
|
expect(HotgameBridgeActions.normalize('pay'), 'recharge');
|
|
expect(HotgameBridgeActions.normalize('gameRecharge'), 'recharge');
|
|
expect(HotgameBridgeActions.normalize('quit'), 'quit');
|
|
expect(HotgameBridgeActions.normalize('closeGame'), 'quit');
|
|
expect(HotgameBridgeActions.normalize('destroy'), 'quit');
|
|
});
|
|
|
|
test('parses hotgame bridge payload maps', () {
|
|
final message = HotgameBridgeMessage.parse(
|
|
'{"action":"gameRecharge","payload":{"source":"button"}}',
|
|
);
|
|
|
|
expect(message.action, HotgameBridgeActions.recharge);
|
|
expect(message.payload['source'], 'button');
|
|
});
|
|
|
|
test(
|
|
'bootstrap script contains documented hotgame client bridge methods',
|
|
() {
|
|
final script = HotgameJsBridge.bootstrapScript();
|
|
|
|
expect(script, contains('window.JsBridge'));
|
|
expect(script, contains("installJsBridgeFunction('recharge'"));
|
|
expect(script, contains("installJsBridgeFunction('quit'"));
|
|
expect(script, contains("installWebkitHandler('recharge'"));
|
|
expect(script, contains("installWebkitHandler('quit'"));
|
|
expect(script, contains('window.rechargeSuccess'));
|
|
},
|
|
);
|
|
|
|
test('detects hotgame room game list items', () {
|
|
const item = RoomGameListItemModel(
|
|
gameId: 'hg_1',
|
|
provider: 'HOTGAME',
|
|
gameType: 'HOTGAME',
|
|
providerGameId: 'Seven7',
|
|
name: 'Lucky77',
|
|
cover: '',
|
|
category: 'CHAT_ROOM',
|
|
sort: 1,
|
|
launchMode: 'H5_REMOTE',
|
|
fullScreen: false,
|
|
gameMode: 3,
|
|
safeHeight: 0,
|
|
orientation: 0,
|
|
packageVersion: '2026',
|
|
status: 'ENABLED',
|
|
launchParams: <String, dynamic>{'screenMode': 'seven'},
|
|
);
|
|
|
|
expect(item.isHotgame, isTrue);
|
|
expect(item.isBaishun, isFalse);
|
|
expect(item.isLeader, isFalse);
|
|
});
|
|
}
|