Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit test #74

Merged
merged 1 commit into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions test/moderation_settings/screens/community_type_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,77 @@ import 'package:post/moderation_settings/screens/community_type_screen.dart';

void main() {
group('test the is Selected cahgned or not', () {
test(' ', () {
test(' index and is plus 18 both changed ', () {
final EditMuted = ComuunityTypesScreenState();
EditMuted.initialIndex = 12;
EditMuted.initialIsPlus18 = true;

EditMuted.index = 6;
EditMuted.initialIsPlus18 = false;
EditMuted.isPlus18 = false;
// login.inputUserNameController.text = 'asdwa';
EditMuted.changeCommunityType();
expect(EditMuted.isSlected, true);
});
test('user name is not empty ', () {
test('is plus 18 only changed ', () {
final EditMuted = ComuunityTypesScreenState();
EditMuted.initialIndex = 12;
EditMuted.initialIsPlus18 = true;

EditMuted.index = 12;
EditMuted.initialIsPlus18 = false;
EditMuted.isPlus18 = false;
// login.inputUserNameController.text = 'asdwa';
EditMuted.changeCommunityType();
expect(EditMuted.isSlected, true);
});
test('user name is not empty ', () {
test('index only changed ', () {
final EditMuted = ComuunityTypesScreenState();
EditMuted.initialIndex = 12;
EditMuted.initialIsPlus18 = true;

EditMuted.index = 6;
EditMuted.initialIsPlus18 = true;
EditMuted.isPlus18 = true;
// login.inputUserNameController.text = 'asdwa';
EditMuted.changeCommunityType();
expect(EditMuted.isSlected, true);
});
test('user name is not empty ', () {
test('both the same ', () {
final EditMuted = ComuunityTypesScreenState();
EditMuted.initialIndex = 12;
EditMuted.initialIsPlus18 = true;

EditMuted.index = 12;
EditMuted.initialIsPlus18 = true;
EditMuted.isPlus18 = true;
// login.inputUserNameController.text = 'asdwa';
EditMuted.changeCommunityType();
expect(EditMuted.isSlected, false);
});
});
group('test changeType', () {
test(' ', () {
final EditMuted = ComuunityTypesScreenState();
EditMuted.index = 12.0;
EditMuted.changeType(20.0);
// login.inputUserNameController.text = 'asdwa';
EditMuted.changeCommunityType();
expect(EditMuted.index.toDouble(), 20.0);
});
});
group('changePlus18', () {
test(' ', () {
final EditMuted = ComuunityTypesScreenState();
EditMuted.isPlus18 = true;
EditMuted.changePlus18();
// login.inputUserNameController.text = 'asdwa';
EditMuted.changeCommunityType();
expect(EditMuted.isPlus18, false);
});
test(' ', () {
final EditMuted = ComuunityTypesScreenState();
EditMuted.isPlus18 = false;
EditMuted.changePlus18();
// login.inputUserNameController.text = 'asdwa';
EditMuted.changeCommunityType();
expect(EditMuted.isPlus18, true);
});
});
}
19 changes: 19 additions & 0 deletions test/moderation_settings/screens/description_screen_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:post/moderation_settings/screens/description_screen.dart';

void main() {
group('check change focus', () {
test(' test change description when the new value is the initial ', () {
final EditMuted = DescriptionState();
EditMuted.initialDescription = 'hamada';
EditMuted.changeDescription('hamada');
expect(EditMuted.isSlected, false);
});
test(' test change description when the new value is not the initial ', () {
final EditMuted = DescriptionState();
EditMuted.initialDescription = 'hamada';
EditMuted.changeDescription('yaser');
expect(EditMuted.isSlected, true);
});
});
}
19 changes: 19 additions & 0 deletions test/moderation_settings/screens/location_screen_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter_test/flutter_test.dart';
import '../../../lib/moderation_settings/screens/location_screen.dart';

void main() {
group('check change focus', () {
test(' test change description when the new value is the initial ', () {
final EditMuted = LocationScreenState();
EditMuted.initialDescription = 'hamada';
EditMuted.changeDescription('hamada');
expect(EditMuted.isSlected, false);
});
test(' test change description when the new value is not the initial ', () {
final EditMuted = LocationScreenState();
EditMuted.initialDescription = 'hamada';
EditMuted.changeDescription('yaser');
expect(EditMuted.isSlected, true);
});
});
}