From 84911e36c4f7381a0b8d57c6e88f4f640e9c824f Mon Sep 17 00:00:00 2001 From: Amir Panahandeh Date: Sun, 25 Aug 2024 22:37:33 +0330 Subject: [PATCH] Add test --- .../test/widgets/autoformats_test.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/fleather/test/widgets/autoformats_test.dart b/packages/fleather/test/widgets/autoformats_test.dart index 17c233bf..d0d60182 100644 --- a/packages/fleather/test/widgets/autoformats_test.dart +++ b/packages/fleather/test/widgets/autoformats_test.dart @@ -1,12 +1,30 @@ import 'package:fleather/fleather.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; + +class MockAutoFormat extends Mock implements AutoFormat {} + +class MockAutoFormatResult extends Mock implements AutoFormatResult {} void main() { late AutoFormats autoformats; setUp(() { autoformats = AutoFormats.fallback(); + registerFallbackValue(ParchmentDocument()); + }); + + test('Can use custom formats with fallbacks', () { + final customAutoformat = MockAutoFormat(); + final document = ParchmentDocument(); + final position = 5; + final data = 'Test'; + when(() => customAutoformat.apply(any(), any(), any())) + .thenReturn(MockAutoFormatResult()); + final formats = AutoFormats.fallback([customAutoformat]); + formats.run(document, position, data); + verify(() => customAutoformat.apply(document, position, data)); }); group('Link detection', () {