-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
scoped_test.dart
30 lines (27 loc) · 858 Bytes
/
scoped_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:test/test.dart';
// Project imports:
import 'package:katana_scoped/katana_scoped.dart';
void main() {
test("Reset Test", () async {
WidgetsFlutterBinding.ensureInitialized();
final container = ScopedValueContainer();
final appRef = AppRef(scopedValueContainer: container);
final n1 = appRef.watch((ref) => ValueNotifier(0));
expect(n1.value, 0);
n1.value = 1;
final n2 = appRef.watch((ref) => ValueNotifier(0));
expect(n2.value, 1);
expect(n1 == n2, true);
appRef.reset();
final n3 = appRef.watch((ref) => ValueNotifier(2));
expect(n3.value, 2);
expect(n1 != n3, true);
n3.value = 4;
final n4 = appRef.watch((ref) => ValueNotifier(2));
expect(n4.value, 4);
expect(n3 == n4, true);
});
}