Skip to content

Commit

Permalink
Refactor family_test.dart to include getKeys() method
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyus committed Mar 15, 2024
1 parent 5396304 commit 43a7154
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/state_beacon_core/test/src/beacons/family_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,23 @@ void main() {
final beacon1 = family(1);
final beacon2 = family(2);

List<WritableBeacon<String>> getBeacons() =>
family.entries.value.map((e) => e.value).toList();
List<WritableBeacon<String>> getBeacons() {
return family.entries.value.map((e) => e.value).toList();
}

List<int> getKeys() {
return family.entries.value.map((e) => e.key).toList();
}

expect(getBeacons(), [beacon1, beacon2]);
expect(getKeys(), [1, 2]);

family.entries.subscribe((_) => ran++, synchronous: true, startNow: false);

final beacon3 = family(3);

expect(getBeacons(), [beacon1, beacon2, beacon3]);
expect(getKeys(), [1, 2, 3]);

expect(ran, 1);

Expand All @@ -163,18 +170,21 @@ void main() {
beacon1.dispose();

expect(getBeacons(), [beacon2, beacon3]);
expect(getKeys(), [2, 3]);

expect(ran, 2);

family.remove(2);

expect(getBeacons(), [beacon3]);
expect(getKeys(), [3]);

expect(ran, 3);

final beacon4 = family(4);

expect(getBeacons(), [beacon3, beacon4]);
expect(getKeys(), [3, 4]);

expect(ran, 4);

Expand All @@ -184,6 +194,7 @@ void main() {
family.clear();

expect(getBeacons(), isEmpty);
expect(getKeys(), isEmpty);

expect(ran, 5);
});
Expand Down

0 comments on commit 43a7154

Please sign in to comment.