Skip to content

Commit

Permalink
Update library test and fix issue reported by 'analyze'
Browse files Browse the repository at this point in the history
  • Loading branch information
edsonjab committed Oct 1, 2024
1 parent dbe93d9 commit 5997eb1
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 135 deletions.
1 change: 1 addition & 0 deletions packages/core/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dev_dependencies:
build_runner: ^2.3.3
flutter_test:
sdk: flutter
test: ^1.25.7
fake_async: ^1.0.0
state_notifier_test: ^0.0.10
flutter_lints: ^2.0.0
Expand Down
14 changes: 7 additions & 7 deletions packages/core/test/flush_policies/timer_flush_policy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {

expect(policy.shouldFlush, isFalse); // Initially shouldFlush is false

async.elapse(Duration(milliseconds: 1000)); // Advance time by 1 second
async.elapse(const Duration(milliseconds: 1000)); // Advance time by 1 second
expect(policy.shouldFlush, isTrue); // After 1 second, shouldFlush should be true
});
});
Expand All @@ -24,14 +24,14 @@ void main() {
final event = TrackEvent("Test"); // Asegúrate de definir RawEvent o usa un mock si es una clase compleja
policy.start();

async.elapse(Duration(milliseconds: 500)); // Advance time by 0.5 second
async.elapse(const Duration(milliseconds: 500)); // Advance time by 0.5 second
expect(policy.shouldFlush, isFalse); // shouldFlush is still false

policy.onEvent(event); // Reset the timer
async.elapse(Duration(milliseconds: 500)); // Advance time by another 0.5 second
async.elapse(const Duration(milliseconds: 500)); // Advance time by another 0.5 second
expect(policy.shouldFlush, isFalse); // shouldFlush is still false because the timer was reset

async.elapse(Duration(milliseconds: 500)); // Advance time by another 0.5 second
async.elapse(const Duration(milliseconds: 500)); // Advance time by another 0.5 second
expect(policy.shouldFlush, isTrue); // After 1 second from the reset, shouldFlush should be true
});
});
Expand All @@ -41,14 +41,14 @@ void main() {
final policy = TimerFlushPolicy(1000); // 1000 milliseconds = 1 second
policy.start();

async.elapse(Duration(milliseconds: 500)); // Advance time by 0.5 second
async.elapse(const Duration(milliseconds: 500)); // Advance time by 0.5 second
expect(policy.shouldFlush, isFalse); // shouldFlush is still false

policy.reset(); // Reset the timer
async.elapse(Duration(milliseconds: 500)); // Advance time by another 0.5 second
async.elapse(const Duration(milliseconds: 500)); // Advance time by another 0.5 second
expect(policy.shouldFlush, isFalse); // shouldFlush is still false because the timer was reset

async.elapse(Duration(milliseconds: 500)); // Advance time by another 0.5 second
async.elapse(const Duration(milliseconds: 500)); // Advance time by another 0.5 second
expect(policy.shouldFlush, isTrue); // After 1 second from the reset, shouldFlush should be true
});
});
Expand Down
Loading

0 comments on commit 5997eb1

Please sign in to comment.