feat(apps/chat): 新增 UI Schema 导航和路由导航工具
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:social_app/features/chat/ui/navigation/ui_schema_navigation.dart';
|
||||
|
||||
void main() {
|
||||
test('buildUiSchemaNavigationTarget merges scalar params only', () {
|
||||
final target = buildUiSchemaNavigationTarget(
|
||||
path: '/calendar/dayweek',
|
||||
params: {
|
||||
'date': '2026-03-18',
|
||||
'from': 'home',
|
||||
'count': 2,
|
||||
'enabled': true,
|
||||
'ignored': {'nested': true},
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
target,
|
||||
'/calendar/dayweek?date=2026-03-18&from=home&count=2&enabled=true',
|
||||
);
|
||||
});
|
||||
|
||||
test('isValidInternalNavigationPath follows protocol constraints', () {
|
||||
expect(isValidInternalNavigationPath('/todo/123/edit'), true);
|
||||
expect(isValidInternalNavigationPath('https://evil.com'), false);
|
||||
expect(isValidInternalNavigationPath('/todo/123?x=1'), false);
|
||||
expect(isValidInternalNavigationPath('/todo/:id'), false);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user