import 'package:test/test.dart'; void main() { group('URL Extraction from HTML', () { test('should extract URL from HTML anchor tag', () { // Access the private method through reflection or create a test helper // For now, let's test the functionality indirectly by testing the regex pattern final input = 'https://www.youtube.com/watch?v=dpx6L15oA4k'; final aTagRegex = RegExp(r']*>.*?', caseSensitive: false); final match = aTagRegex.firstMatch(input); expect(match, isNotNull); expect(match!.group(1), equals('https://www.youtube.com/watch?v=dpx6L15oA4k')); }); test('should return original string if not HTML anchor tag', () { final input = 'https://www.youtube.com/watch?v=dpx6L15oA4k'; final aTagRegex = RegExp(r']*>.*?', caseSensitive: false); final match = aTagRegex.firstMatch(input); expect(match, isNull); }); test('should handle various HTML anchor tag formats', () { final testCases = [ 'Link', 'Link', 'Link', 'Link Text', ]; final aTagRegex = RegExp(r']*>.*?', caseSensitive: false); for (final testCase in testCases) { final match = aTagRegex.firstMatch(testCase); expect(match, isNotNull, reason: 'Failed to match: $testCase'); expect(match!.group(1), equals('https://example.com')); } }); test('should handle empty or whitespace input', () { final testCases = ['', ' ', '\t\n']; final aTagRegex = RegExp(r']*>.*?', caseSensitive: false); for (final testCase in testCases) { final match = aTagRegex.firstMatch(testCase.trim()); expect(match, isNull, reason: 'Should not match empty/whitespace: "$testCase"'); } }); }); }