diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index a20b188..fa0933b 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -121,7 +121,12 @@ void main() { await tester.tap(find.byType(SwitchListTile).at(0)); await tester.tap(find.byType(SwitchListTile).at(1)); await tester.pump(const Duration(seconds: 1)); + await tester.tap(find.byType(SwitchListTile).at(2)); + await tester.pump(const Duration(seconds: 1)); await tester.tap(find.byType(SwitchListTile).at(1)); + await tester.tap(find.byType(SwitchListTile).at(0)); + + await tester.tap(find.byType(ElevatedButton)); }); testWidgets('Test Message page', (tester) async { diff --git a/test/widget_test.dart b/test/widget_test.dart index 143b1bc..b03b653 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,6 +5,7 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. +import 'package:eduapge2/api.dart'; import 'package:eduapge2/home.dart'; import 'package:eduapge2/messages.dart'; import 'package:flutter/material.dart'; @@ -55,6 +56,59 @@ void main() { expect(testList[4] == 4, true), }); }); + + group('API', () { + group('Recipient', () { + Recipient recipient = Recipient( + id: "-1", type: RecipientType.student, name: "Test Recipient"); + + test( + 'recipientString', + () => { + expect(recipient.recipientString(false), "StudentOnly-1"), + expect(recipient.recipientString(true), "Student-1"), + recipient.type = RecipientType.teacher, + expect(recipient.recipientString(false), "Ucitel-1"), + }); + }); + + group('MessageOptions', () { + test('toJson', () { + MessageOptions options = MessageOptions( + text: "Test message", + important: true, + ); + expect(options.toJson(), { + "text": "Test message", + "important": true, + "poll": null, + }); + }); + + test('toJson with poll', () { + PollOption opt = PollOption(text: "Option 1", id: "opt1"); + PollOptions poll = PollOptions( + multiple: true, + options: [opt], + ); + MessageOptions options = MessageOptions( + text: "Test message", + important: true, + poll: poll, + ); + expect(options.toJson(), { + "text": "Test message", + "important": true, + "poll": { + "multiple": true, + "options": [ + {"text": "Option 1", "id": "opt1"} + ] + }, + }); + }); + }); + }); } class LocalizationsInj extends StatelessWidget {