diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 18:55:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 18:55:57 +0100 |
| commit | 6060c43bee23ebae41edbe914ba991ebf0a96924 (patch) | |
| tree | a7057786b91e25048eb1eb47f960dcb33ecbbbc1 /server/test/net | |
| parent | 7ee14396b1f1f96ed0472b5949ce82a7f9313276 (diff) | |
server: type the JSON parsing boundaries (avoid_dynamic_calls)
Give the decoded JSON values a static type before use: cast the
monster-ability card list to List<List<Object?>> (and the graphic
extras to Map entries), the summon payload to Map<String, dynamic>,
room data lists/maps explicitly, and deck card lists to
Map<String, dynamic> loop variables. The test assertions on the
settings payload get the same treatment. Also drops two stale
ignore comments (wrong lint code) and a redundant nested assignment.
Diffstat (limited to 'server/test/net')
| -rw-r--r-- | server/test/net/settings_test.dart | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/server/test/net/settings_test.dart b/server/test/net/settings_test.dart index 677af11..900039b 100644 --- a/server/test/net/settings_test.dart +++ b/server/test/net/settings_test.dart @@ -97,8 +97,8 @@ void main() { final aliceGot = await table.alice.nextOf('settings'); final bobGot = await table.bob.nextOf('settings'); - expect(aliceGot['settings']['hideLootDeck'], isTrue); - expect(bobGot['settings']['hideLootDeck'], isTrue); + expect((aliceGot['settings'] as Map)['hideLootDeck'], isTrue); + expect((bobGot['settings'] as Map)['hideLootDeck'], isTrue); expect(getIt<Settings>().hideLootDeck, isTrue); // A reconnecting client sees it in the welcome too. @@ -335,7 +335,7 @@ void main() { table.alice.send(Protocol.saveMessage('alpha')); final saved = await table.alice.nextOf('settings'); - expect(saved['settings']['saves'], ['alpha']); + expect((saved['settings'] as Map)['saves'], ['alpha']); expect(getIt<Settings>().saves.keys, contains('alpha')); // Change the state: add a monster (index 2). @@ -377,7 +377,7 @@ void main() { // Delete the save; loading it after is rejected. table.alice.send(Protocol.deleteSaveMessage('alpha')); final deleted = await table.alice.nextOf('settings'); - expect(deleted['settings']['saves'], isEmpty); + expect((deleted['settings'] as Map)['saves'], isEmpty); expect(getIt<Settings>().saves.keys, isEmpty); table.alice.send(Protocol.loadSaveMessage('alpha')); @@ -402,7 +402,7 @@ void main() { // No error: deleting an unknown save is a silent no-op (the // reference's deleteSave just removes from the map). final settings = await table.alice.nextOf('settings'); - expect(settings['settings']['saves'], isEmpty); + expect((settings['settings'] as Map)['saves'], isEmpty); } finally { await table.teardown(); } @@ -419,7 +419,7 @@ void main() { Protocol.saveCharacterMessage('Blinky backup', 'Blinkblade'), ); final saved = await table.alice.nextOf('settings'); - final characterSaves = saved['settings']['characterSaves'] as List; + final characterSaves = (saved['settings'] as Map)['characterSaves'] as List; expect( characterSaves, [{ @@ -452,7 +452,7 @@ void main() { Protocol.deleteCharacterSaveMessage('Blinky backup\nBlinkblade'), ); final deleted = await table.alice.nextOf('settings'); - expect(deleted['settings']['characterSaves'], isEmpty); + expect((deleted['settings'] as Map)['characterSaves'], isEmpty); table.alice.send( Protocol.loadCharacterSaveMessage('Blinky backup\nBlinkblade'), |
