Skip to content

Commit 13b7e6d

Browse files
authored
test: action should wrap in transaction (#833)
Signed-off-by: Minsu Lee <amond@amond.net> Signed-off-by: Minsu Lee <amond@amond.net>
1 parent 4395c8c commit 13b7e6d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mobx/test/action_test.dart

+18
Original file line numberDiff line numberDiff line change
@@ -327,5 +327,23 @@ void main() {
327327

328328
d();
329329
});
330+
331+
test('action should wrap in transaction', () {
332+
final values = [];
333+
final observable = Observable(0);
334+
335+
autorun((_) => values.add(observable.value));
336+
337+
final increment = Action((int amount) {
338+
observable.value = observable.value + amount * 2; // 14
339+
observable.value = observable.value - amount; // 7
340+
}, name: 'increment');
341+
342+
expect(increment, isA<Action>());
343+
344+
increment([7]);
345+
346+
expect(values, [0, 7]);
347+
});
330348
});
331349
}

0 commit comments

Comments
 (0)