Files
meshcore-open/test/connector/mention_detection_test.dart
T
zjs81 f667320608 Fix review findings in channel notification modes
- Detect mentions on the original text, as @[name] or a whole-word @name
- Save and restore the full mode map in review mode
- Open the mode picker from the chat bell and show the mode in its tooltip
- Share one mode picker sheet; fix the stale sheet context
- Persist modes by name and skip unknown entries
- Keep writing muted_channels so older builds keep the user's mutes
- Remove the muteChannel/unmuteChannel/isChannelMuted shims
- Update notifications docs to match the behaviour
2026-10-24 20:46:49 -07:00

34 lines
1.2 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/connector/meshcore_connector.dart';
void main() {
bool mentions(String text, String? name) =>
MeshCoreConnector.textMentionsName(text, name);
test('matches bracketed and plain mentions case-insensitively', () {
expect(mentions('@[Bob] hello', 'Bob'), isTrue);
expect(mentions('hey @[bob]', 'Bob'), isTrue);
expect(mentions('hey @bob, look', 'Bob'), isTrue);
expect(mentions('@BOB', 'Bob'), isTrue);
expect(mentions('ping @Иван!', 'иван'), isTrue);
});
test('requires a word boundary for plain mentions', () {
expect(mentions('hey @bobby', 'Bob'), isFalse);
expect(mentions('mail x@bob.com', 'Bob'), isFalse);
expect(mentions('hey bob', 'Bob'), isFalse);
});
test('names with spaces or regex characters must match in full', () {
expect(mentions('hi @Bob Smith', 'Bob Smith'), isTrue);
expect(mentions('hi @Bob', 'Bob Smith'), isFalse);
expect(mentions('@[Node (1)] ok', 'Node (1)'), isTrue);
expect(mentions('@[Node 1] ok', 'Node (1)'), isFalse);
});
test('no self name never matches', () {
expect(mentions('@[Bob] hi', null), isFalse);
expect(mentions('@ hi', ''), isFalse);
});
}