Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Apr 25, 2024
1 parent dca3198 commit 5ec4a0e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
5 changes: 5 additions & 0 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
54 changes: 54 additions & 0 deletions test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5ec4a0e

Please sign in to comment.