mirror of
https://github.com/rrousselGit/riverpod.git
synced 2025-08-15 02:06:53 +08:00

<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - Refactor - Generated provider names were simplified: symbols now end with "Provider" instead of "NotifierProvider". Update any app references and samples. - Documentation - README and docs clarify the default strip pattern and examples now use the new ...Provider names. - Tests - Updated and added tests to assert the new default naming behavior. - Chores - Configuration parsing tightened to always supply default naming values. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
29 lines
846 B
Dart
29 lines
846 B
Dart
// ignore_for_file: unused_local_variable
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
import 'notifier_mock/codegen.dart';
|
|
|
|
/* SNIPPET START */
|
|
void main() {
|
|
test('Some description', () {
|
|
final container = ProviderContainer.test(
|
|
// {@template overrides}
|
|
// Override the provider to have it create our mock Notifier.
|
|
// {@endtemplate}
|
|
overrides: [myProvider.overrideWith(MyNotifierMock.new)],
|
|
);
|
|
|
|
// {@template readNotifier}
|
|
// Then obtain the mocked notifier through the container:
|
|
// {@endtemplate}
|
|
final notifier = container.read(myProvider.notifier);
|
|
|
|
// {@template interactNotifier}
|
|
// You can then interact with the notifier as you would with the real one:
|
|
// {@endtemplate}
|
|
notifier.state = 42;
|
|
});
|
|
}
|