mirror of
https://github.com/block/buzz.git
synced 2026-10-30 22:11:36 +00:00
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
102 lines
2.5 KiB
Dart
102 lines
2.5 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:buzz/shared/relay/nostr_models.dart';
|
|
|
|
void main() {
|
|
test('NostrFilter serializes and preserves authors', () {
|
|
const filter = NostrFilter(
|
|
kinds: [EventKind.readState],
|
|
authors: ['pubkey-a'],
|
|
tags: {
|
|
'#t': ['read-state'],
|
|
},
|
|
since: 10,
|
|
limit: 5,
|
|
);
|
|
|
|
expect(filter.toJson(), {
|
|
'kinds': [EventKind.readState],
|
|
'limit': 5,
|
|
'authors': ['pubkey-a'],
|
|
'since': 10,
|
|
'#t': ['read-state'],
|
|
});
|
|
|
|
final copied = filter.copyWithSince(20);
|
|
expect(copied.toJson(), {
|
|
'kinds': [EventKind.readState],
|
|
'limit': 5,
|
|
'authors': ['pubkey-a'],
|
|
'since': 20,
|
|
'#t': ['read-state'],
|
|
});
|
|
});
|
|
|
|
test('NostrFilter can serialize broad deletion subscriptions', () {
|
|
const filter = NostrFilter(kinds: [EventKind.deletion], limit: 0);
|
|
|
|
expect(filter.toJson(), {
|
|
'kinds': [EventKind.deletion],
|
|
'limit': 0,
|
|
});
|
|
});
|
|
|
|
test('NostrFilter serializes relay query extensions', () {
|
|
const filter = NostrFilter(
|
|
kinds: EventKind.channelTimelineContentKinds,
|
|
tags: {
|
|
'#h': ['channel-id'],
|
|
},
|
|
limit: 50,
|
|
extensions: {
|
|
'top_level': true,
|
|
'include_summaries': true,
|
|
'include_aux': true,
|
|
'before_id': 'cursor-id',
|
|
},
|
|
);
|
|
|
|
expect(filter.toJson(), {
|
|
'kinds': EventKind.channelTimelineContentKinds,
|
|
'limit': 50,
|
|
'#h': ['channel-id'],
|
|
'top_level': true,
|
|
'include_summaries': true,
|
|
'include_aux': true,
|
|
'before_id': 'cursor-id',
|
|
});
|
|
});
|
|
|
|
test('channel unread activity kinds exclude non-message updates', () {
|
|
expect(
|
|
EventKind.channelMessageEventKinds,
|
|
contains(EventKind.streamMessage),
|
|
);
|
|
expect(EventKind.channelMessageEventKinds, contains(EventKind.forumPost));
|
|
expect(
|
|
EventKind.channelMessageEventKinds,
|
|
contains(EventKind.forumComment),
|
|
);
|
|
|
|
expect(
|
|
EventKind.channelMessageEventKinds,
|
|
isNot(contains(EventKind.reaction)),
|
|
);
|
|
expect(
|
|
EventKind.channelMessageEventKinds,
|
|
isNot(contains(EventKind.streamMessageEdit)),
|
|
);
|
|
expect(
|
|
EventKind.channelMessageEventKinds,
|
|
isNot(contains(EventKind.streamMessageDiff)),
|
|
);
|
|
expect(
|
|
EventKind.channelMessageEventKinds,
|
|
isNot(contains(EventKind.deletion)),
|
|
);
|
|
expect(
|
|
EventKind.channelMessageEventKinds,
|
|
isNot(contains(EventKind.systemMessage)),
|
|
);
|
|
});
|
|
}
|