feat: DeviceListModifiedEvent now contains a delta

This commit is contained in:
2023-06-16 20:13:30 +02:00
parent 0b2d6f0a97
commit e6c792a8ac
4 changed files with 85 additions and 11 deletions

33
test/helpers_test.dart Normal file
View File

@@ -0,0 +1,33 @@
import 'package:omemo_dart/src/helpers.dart';
import 'package:omemo_dart/src/omemo/queue.dart';
import 'package:test/test.dart';
void main() {
group('List diff', () {
test('Empty list to full list', () {
final result = <int>[].diff([1, 2, 3, 4]);
expect(result.removed, isEmpty);
expect(
result.added.containsAll([1, 2, 3, 4]),
isTrue,
);
expect(result.added.length, 4);
});
test('Full list to empty list', () {
final result = [1, 2, 3, 4].diff([]);
expect(result.added, isEmpty);
expect(
result.removed.containsAll([1, 2, 3, 4]),
isTrue,
);
expect(result.removed.length, 4);
});
test('Full list to full list', () {
final result = [1, 2, 3, 4].diff([1, 2, 4, 5]);
expect(result.added, [5]);
expect(result.removed, [3]);
});
});
}