Fix cannot auto create tag when paste list email and switch focus
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -41,24 +41,24 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('StringConvert::extractStrings::', () {
|
||||
group('StringConvert::extractEmailAddress::', () {
|
||||
group('Basic Functionality', () {
|
||||
test('should extract strings separated by spaces', () {
|
||||
test('should not extract strings separated by spaces', () {
|
||||
const input = 'user1@example.com user2@example.com';
|
||||
final expected = ['user1@example.com', 'user2@example.com'];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
final expected = ['user1@example.com user2@example.com'];
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should extract strings separated by commas', () {
|
||||
const input = 'user1@example.com,user2@example.com';
|
||||
final expected = ['user1@example.com', 'user2@example.com'];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should extract strings separated by semicolons', () {
|
||||
const input = 'user1@example.com;user2@example.com';
|
||||
final expected = ['user1@example.com', 'user2@example.com'];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should extract strings separated by mixed separators', () {
|
||||
@@ -68,7 +68,7 @@ void main() {
|
||||
'user2@example.com',
|
||||
'user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should handle multiple consecutive separators', () {
|
||||
@@ -79,7 +79,7 @@ void main() {
|
||||
'user2@example.com',
|
||||
'user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,19 +87,19 @@ void main() {
|
||||
test('should handle empty input', () {
|
||||
const input = '';
|
||||
final expected = <String>[];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should handle input with only separators', () {
|
||||
const input = ',, ;; ';
|
||||
final expected = <String>[];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should handle trailing and leading separators', () {
|
||||
const input = ', user1@example.com; user2@example.com ,';
|
||||
final expected = ['user1@example.com', 'user2@example.com'];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should handle extra spaces between separators', () {
|
||||
@@ -109,7 +109,7 @@ void main() {
|
||||
'user2@example.com',
|
||||
'user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -118,11 +118,11 @@ void main() {
|
||||
final input = List.generate(
|
||||
1000,
|
||||
(index) =>
|
||||
'user$index@example.com${index % 3 == 0 ? ',' : index % 3 == 1 ? ';' : ' '}',
|
||||
'user$index@example.com${index % 3 == 0 ? ',' : ';'}',
|
||||
).join();
|
||||
final expected =
|
||||
List.generate(1000, (index) => 'user$index@example.com');
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -130,43 +130,37 @@ void main() {
|
||||
test('should handle URL encoded input', () {
|
||||
String input = 'user1%40example.com%20user2%40example.com%20user3%40example.com';
|
||||
final expected = [
|
||||
'user1@example.com',
|
||||
'user2@example.com',
|
||||
'user3@example.com'
|
||||
'user1@example.com user2@example.com user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should handle Base64 encoded input', () {
|
||||
String input = 'dXNlcjFAZXhhbXBsZS5jb20gdXNlcjJAZXhhbXBsZS5jb20gdXNlcjNAZXhhbXBsZS5jb20=';
|
||||
final expected = [
|
||||
'user1@example.com',
|
||||
'user2@example.com',
|
||||
'user3@example.com'
|
||||
'user1@example.com user2@example.com user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should handle input with both URL encoding and Base64 encoding', () {
|
||||
String input = Uri.encodeComponent(base64.encode(utf8.encode('user1@example.com user2@example.com user3@example.com')));
|
||||
final expected = [
|
||||
'user1@example.com',
|
||||
'user2@example.com',
|
||||
'user3@example.com'
|
||||
'user1@example.com user2@example.com user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
});
|
||||
|
||||
group('Failing Cases', () {
|
||||
test('should return empty list for empty input', () {
|
||||
String input = '';
|
||||
expect(StringConvert.extractStrings(input), equals([]));
|
||||
expect(StringConvert.extractEmailAddress(input), equals([]));
|
||||
});
|
||||
|
||||
test('should return empty list if input is only separators', () {
|
||||
String input = ' , ; ';
|
||||
expect(StringConvert.extractStrings(input), equals([]));
|
||||
expect(StringConvert.extractEmailAddress(input), equals([]));
|
||||
});
|
||||
|
||||
test('should return correct result for input with invalid separators', () {
|
||||
@@ -176,23 +170,22 @@ void main() {
|
||||
'user2@example.com',
|
||||
'user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
|
||||
test('should return empty list for input with only whitespace and separators', () {
|
||||
String input = ' , ; \n';
|
||||
expect(StringConvert.extractStrings(input), equals([]));
|
||||
expect(StringConvert.extractEmailAddress(input), equals([]));
|
||||
});
|
||||
|
||||
test('should handle input with newline characters', () {
|
||||
// Arrange
|
||||
String input = 'user1@example.com\nuser2@example.com;user3@example.com';
|
||||
final expected = [
|
||||
'user1@example.com',
|
||||
'user2@example.com',
|
||||
'user1@example.com user2@example.com',
|
||||
'user3@example.com'
|
||||
];
|
||||
expect(StringConvert.extractStrings(input), equals(expected));
|
||||
expect(StringConvert.extractEmailAddress(input), equals(expected));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user