Skip to content

Commit

Permalink
test: add atom_test
Browse files Browse the repository at this point in the history
  • Loading branch information
amondnet committed Jan 27, 2023
1 parent 0a2b5c8 commit f503a2e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
7 changes: 7 additions & 0 deletions mobx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.1.4

- Allow users to bypass observability system for performance by [@fzyzcjy](https://github.com/fzyzcjy) in [#844](https://github.com/mobxjs/mobx.dart/pull/844)
- Avoid unnecessary observable notifications of @observable fields of Stores by [@fzyzcjy](https://github.com/fzyzcjy) in [#844](https://github.com/mobxjs/mobx.dart/pull/844)
- Fix Reaction lacks toString, so cannot see which reaction causes the error by [@fzyzcjy](https://github.com/fzyzcjy) in [#844](https://github.com/mobxjs/mobx.dart/pull/844)
- Add StackTrace to reactions in debug mode to easily spot which reaction it is by [@fzyzcjy](https://github.com/fzyzcjy) in [#844](https://github.com/mobxjs/mobx.dart/pull/844)

## 2.1.2 - 2.1.3

- Fix tests in dart 2.19 - [@amondnet](https://github.com/amondnet)
Expand Down
2 changes: 1 addition & 1 deletion mobx/lib/version.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated via set_version.dart. !!!DO NOT MODIFY BY HAND!!!

/// The current version as per `pubspec.yaml`.
const version = '2.1.3';
const version = '2.1.4';
2 changes: 1 addition & 1 deletion mobx/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: mobx
version: 2.1.3
version: 2.1.4
description: "MobX is a library for reactively managing the state of your applications. Use the power of observables, actions, and reactions to supercharge your Dart and Flutter apps."

homepage: https://github.com/mobxjs/mobx.dart
Expand Down
3 changes: 3 additions & 0 deletions mobx/test/all_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import 'reactive_policies_test.dart' as reactive_policies_test;
import 'spy_test.dart' as spy_test;
import 'store_test.dart' as store_test;
import 'when_test.dart' as when_test;
import 'atom_test.dart' as atom_test;

void main() {
observable_test.main();
Expand Down Expand Up @@ -71,4 +72,6 @@ void main() {

spy_test.main();
store_test.main();

atom_test.main();
}
31 changes: 31 additions & 0 deletions mobx/test/atom_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:mobx/mobx.dart';
import 'package:mobx/src/utils.dart';
import 'package:test/test.dart';

import 'util.dart';

void main() {
testSetup();

group('Atom', () {
test('toString', () {
final object = Atom(name: 'MyName');
expect(object.toString(), contains('MyName'));
});

test('debugCreationStack', () {
DebugCreationStack.enable = true;
addTearDown(() => DebugCreationStack.enable = false);
final object = Atom();
expect(object.debugCreationStack, isNotNull);
});

test('isBeingObserved', () {
final observable = Observable(1, name: 'MyName');
expect(observable.isBeingObserved, false);
final d = autorun((_) => observable.value);
expect(observable.isBeingObserved, true);
d();
});
});
}

0 comments on commit f503a2e

Please sign in to comment.