* feat: version docs and add stream_member_list_controller docs * feat: add member list and grid doc * exported extensions on ui package * feat: add first version of v5 migration guide * docs: grammar fixes and other v5 release details * docs: add additional v5 migration info * update WrapAttachmentWidget doc * add back v4 migration guide * docs(doc): add customize_attachment_picker_modal.mdx guide. (#1343) Signed-off-by: xsahil03x <[email protected]> Signed-off-by: xsahil03x <[email protected]> * update link for attachment picker guide * update share_plus Signed-off-by: xsahil03x <[email protected]> Co-authored-by: Gordon Hayes <[email protected]> Co-authored-by: Sahil Kumar <[email protected]>
87 lines
2.9 KiB
Dart
87 lines
2.9 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|
|
|
void main() {
|
|
group('List<User>.search', () {
|
|
test('should work fine', () {
|
|
final tommaso = User(id: 'tommaso', name: 'Tommaso');
|
|
final thierry = User(id: 'thierry', name: 'Thierry');
|
|
final users = [tommaso, thierry];
|
|
|
|
expect(users.search('Tom'), [tommaso]);
|
|
expect(users.search('Thier'), [thierry]);
|
|
});
|
|
|
|
test('should search using UpperCased', () {
|
|
final tommaso = User(id: 'tommaso', name: 'Tommaso');
|
|
final thierry = User(id: 'thierry', name: 'Thierry');
|
|
final users = [tommaso, thierry];
|
|
|
|
expect(users.search('tom'), [tommaso]);
|
|
expect(users.search('thier'), [thierry]);
|
|
});
|
|
|
|
test('should search by .id or .name', () {
|
|
final user1 = User(id: 'searchingThis');
|
|
final user2 = User(id: 'x', name: 'searchingThis');
|
|
|
|
expect([user1].search('sear'), [user1]);
|
|
expect([user2].search('sear'), [user2]);
|
|
});
|
|
|
|
test('should search transliterated', () {
|
|
final tommaso = User(id: 'tommaso', name: 'Tommaso');
|
|
final thierry = User(id: 'thierry', name: 'Thierry');
|
|
final users = [tommaso, thierry];
|
|
|
|
expect(users.search('tóm'), [tommaso]);
|
|
expect(users.search('thíer'), [thierry]);
|
|
});
|
|
|
|
test('search and sorted by distance', () {
|
|
final tommaso = User(id: 'tommaso', name: 'Tommaso');
|
|
final tomas = User(id: 'tomas', name: 'Tomas');
|
|
final users = [tommaso, tomas];
|
|
|
|
expect(users.search('tom'), [tomas, tommaso]);
|
|
});
|
|
|
|
test('should work fine with cyrillic diacritics', () {
|
|
final petyo = User(id: '42', name: 'Петьо');
|
|
final anastasia = User(id: '13', name: 'Анастасiя');
|
|
final dmitriy = User(id: '99', name: 'Дмитрий');
|
|
final users = [petyo, anastasia, dmitriy];
|
|
|
|
expect(users.search('petyo'), []);
|
|
expect(users.search('Пе'), [petyo]);
|
|
expect(users.search('Ана'), [anastasia]);
|
|
expect(users.search('Дмитри'), [dmitriy]);
|
|
expect(users.search('Дмитрии'), [dmitriy]);
|
|
});
|
|
|
|
test('should work fine with french diacritics', () {
|
|
final user = User(id: 'fra', name: 'françois');
|
|
|
|
expect([user].search('françois'), [user]);
|
|
expect([user].search('franc'), [user]);
|
|
});
|
|
});
|
|
|
|
group('String.isOnlyEmoji', () {
|
|
test('should return false for empty or > 3 strings', () {
|
|
expect(''.isOnlyEmoji, false);
|
|
expect('aaa📝💜'.isOnlyEmoji, false);
|
|
expect('📝💜📝💜'.isOnlyEmoji, false);
|
|
});
|
|
|
|
test('should detect strings made only by emojis', () {
|
|
expect('a📝💜'.isOnlyEmoji, false);
|
|
expect('📝💜📝'.isOnlyEmoji, true);
|
|
expect('🌶'.isOnlyEmoji, true);
|
|
expect('🌶1'.isOnlyEmoji, false);
|
|
expect('👨👨👨👨'.isOnlyEmoji, true);
|
|
expect('👨👨👨👨 '.isOnlyEmoji, true);
|
|
});
|
|
});
|
|
}
|