58 lines
1.9 KiB
Dart
58 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:lanebow/utils/test_utils.dart';
|
|
import 'package:lanebow/utils/url_utils.dart';
|
|
|
|
void main() {
|
|
setUp(() {
|
|
// 테스트 모드 강제
|
|
TestUtils.setTestMode(true);
|
|
});
|
|
|
|
group('UrlUtils', () {
|
|
test('generatePublicHash - 테스트 모드에서 예측 가능한 해시 반환', () {
|
|
final h1 = UrlUtils.generatePublicHash();
|
|
final h2 = UrlUtils.generatePublicHash();
|
|
expect(h1, isNotEmpty);
|
|
expect(h2, isNotEmpty);
|
|
expect(h1, isNot(h2)); // 카운터 증가로 서로 달라야 함
|
|
expect(h1.startsWith('test'), true);
|
|
expect(h2.startsWith('test'), true);
|
|
});
|
|
|
|
test('getEventPublicUrl - 기본 도메인과 해시 결합', () {
|
|
const hash = 'test42';
|
|
final url = UrlUtils.getEventPublicUrl(hash);
|
|
expect(url, '${UrlUtils.eventBaseUrl}$hash');
|
|
});
|
|
|
|
testWidgets('copyUrlToClipboard - 테스트 모드에서 오류 없이 동작하고 SnackBar 미표시', (tester) async {
|
|
// 테스트 환경에서는 SnackBar를 실제로 띄우지 않고 로그만 출력하도록 구현되어 있음
|
|
final app = MaterialApp(
|
|
home: Scaffold(
|
|
appBar: AppBar(),
|
|
body: Builder(
|
|
builder: (context) {
|
|
return Center(
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
UrlUtils.copyUrlToClipboard(context, 'https://example.com');
|
|
},
|
|
child: const Text('copy'),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
|
|
await tester.pumpWidget(app);
|
|
await tester.tap(find.text('copy'));
|
|
await tester.pump();
|
|
|
|
// SnackBar가 표시되지 않아야 함 (테스트 모드)
|
|
expect(find.byType(SnackBar), findsNothing);
|
|
});
|
|
});
|
|
}
|