-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(neon_rich_text): Separate all tests into multiple files
Signed-off-by: provokateurin <kate@provokateurin.de>
- Loading branch information
1 parent
4f486d7
commit 1338a06
Showing
15 changed files
with
735 additions
and
633 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/neon_framework/packages/neon_rich_text/test/rich_objects/deck_card_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:neon_framework/models.dart'; | ||
import 'package:neon_framework/testing.dart'; | ||
import 'package:neon_framework/widgets.dart'; | ||
import 'package:nextcloud/core.dart' as core; | ||
import 'package:provider/provider.dart'; | ||
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; | ||
|
||
void main() { | ||
late MockUrlLauncher urlLauncher; | ||
late Account account; | ||
|
||
setUpAll(() { | ||
FakeNeonStorage.setup(); | ||
|
||
registerFallbackValue(const LaunchOptions()); | ||
|
||
urlLauncher = MockUrlLauncher(); | ||
// ignore: discarded_futures | ||
when(() => urlLauncher.launchUrl(any(), any())).thenAnswer((_) async => true); | ||
|
||
UrlLauncherPlatform.instance = urlLauncher; | ||
}); | ||
|
||
setUp(() { | ||
account = MockAccount(); | ||
}); | ||
|
||
testWidgets('Deck card', (tester) async { | ||
await tester.pumpWidgetWithAccessibility( | ||
TestApp( | ||
providers: [ | ||
Provider<Account>.value(value: account), | ||
], | ||
child: NeonRichObjectDeckCard( | ||
parameter: core.RichObjectParameter( | ||
(b) => b | ||
..type = core.RichObjectParameter_Type.deckCard | ||
..id = '' | ||
..name = 'name' | ||
..boardname = 'boardname' | ||
..stackname = 'stackname' | ||
..link = '/link', | ||
), | ||
), | ||
), | ||
); | ||
expect(find.text('name'), findsOne); | ||
expect(find.text('boardname: stackname'), findsOne); | ||
await expectLater( | ||
find.byType(NeonRichObjectDeckCard), | ||
matchesGoldenFile('goldens/rich_text_object_deck_card.png'), | ||
); | ||
|
||
await tester.tap(find.byType(NeonRichObjectDeckCard)); | ||
verify(() => urlLauncher.launchUrl('https://cloud.example.com:8443/link', any())).called(1); | ||
}); | ||
} |
102 changes: 102 additions & 0 deletions
102
packages/neon_framework/packages/neon_rich_text/test/rich_objects/fallback_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:neon_framework/models.dart'; | ||
import 'package:neon_framework/testing.dart'; | ||
import 'package:neon_framework/widgets.dart'; | ||
import 'package:nextcloud/core.dart' as core; | ||
import 'package:provider/provider.dart'; | ||
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; | ||
|
||
void main() { | ||
late MockUrlLauncher urlLauncher; | ||
late Account account; | ||
|
||
setUpAll(() { | ||
FakeNeonStorage.setup(); | ||
|
||
registerFallbackValue(const LaunchOptions()); | ||
|
||
urlLauncher = MockUrlLauncher(); | ||
// ignore: discarded_futures | ||
when(() => urlLauncher.launchUrl(any(), any())).thenAnswer((_) async => true); | ||
|
||
UrlLauncherPlatform.instance = urlLauncher; | ||
}); | ||
|
||
setUp(() { | ||
account = MockAccount(); | ||
}); | ||
|
||
group('Fallback', () { | ||
testWidgets('Opens link', (tester) async { | ||
await tester.pumpWidgetWithAccessibility( | ||
TestApp( | ||
providers: [ | ||
Provider<Account>.value(value: account), | ||
], | ||
child: NeonRichObjectFallback( | ||
parameter: core.RichObjectParameter( | ||
(b) => b | ||
..type = core.RichObjectParameter_Type.calendarEvent | ||
..id = '' | ||
..name = 'name' | ||
..link = '/link', | ||
), | ||
textStyle: null, | ||
), | ||
), | ||
); | ||
|
||
await tester.tap(find.byType(NeonRichObjectFallback)); | ||
verify(() => urlLauncher.launchUrl('https://cloud.example.com:8443/link', any())).called(1); | ||
}); | ||
|
||
testWidgets('Without icon', (tester) async { | ||
await tester.pumpWidgetWithAccessibility( | ||
TestApp( | ||
child: NeonRichObjectFallback( | ||
parameter: core.RichObjectParameter( | ||
(b) => b | ||
..type = core.RichObjectParameter_Type.addressbook | ||
..id = '' | ||
..name = 'name', | ||
), | ||
textStyle: null, | ||
), | ||
), | ||
); | ||
expect(find.byType(NeonUriImage), findsNothing); | ||
expect(find.text('name'), findsOne); | ||
await expectLater( | ||
find.byType(NeonRichObjectFallback), | ||
matchesGoldenFile('goldens/rich_text_object_fallback_without_icon.png'), | ||
); | ||
}); | ||
|
||
testWidgets('With icon', (tester) async { | ||
await tester.pumpWidgetWithAccessibility( | ||
TestApp( | ||
providers: [ | ||
Provider<Account>.value(value: account), | ||
], | ||
child: NeonRichObjectFallback( | ||
parameter: core.RichObjectParameter( | ||
(b) => b | ||
..type = core.RichObjectParameter_Type.addressbook | ||
..id = '' | ||
..name = 'name' | ||
..iconUrl = '', | ||
), | ||
textStyle: null, | ||
), | ||
), | ||
); | ||
expect(find.byType(NeonUriImage), findsOne); | ||
expect(find.text('name'), findsOne); | ||
await expectLater( | ||
find.byType(NeonRichObjectFallback), | ||
matchesGoldenFile('goldens/rich_text_object_fallback_with_icon.png'), | ||
); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.