Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir-P committed Aug 25, 2024
1 parent 6b99ce7 commit 84911e3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/fleather/test/widgets/autoformats_test.dart
Original file line number Diff line number Diff line change
@@ -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', () {
Expand Down

0 comments on commit 84911e3

Please sign in to comment.