ModernMemoires/test/question_generator_test.dart

58 lines
2.3 KiB
Dart
Raw Normal View History

2024-01-09 14:29:17 +01:00
import 'package:flutter_test/flutter_test.dart';
import 'package:moody/utils/logic/question_generator.dart';
void main() {
group('QuestionGenerator Tests', () {
test('getQuestionByDate should return a valid question', () {
final QuestionGenerator generator = QuestionGenerator();
// Test with specific dates
final DateTime date1 = DateTime(2024, 1, 10); // Replace with your desired date
final DateTime date2 = DateTime(2024, 1, 11); // Replace with another date
final DateTime date3 = DateTime(2024, 1, 12); // Replace with yet another date
final String question1 = generator.getQuestionByDate(date1);
final String question2 = generator.getQuestionByDate(date2);
final String question3 = generator.getQuestionByDate(date3);
// Assert that the generated questions are not null
expect(question1, isNotNull);
expect(question2, isNotNull);
expect(question3, isNotNull);
// Add more test cases...
});
test('getQuestionByDate should return different questions for different dates', () {
final QuestionGenerator generator = QuestionGenerator();
// Test with specific dates
final DateTime date1 = DateTime(2024, 1, 10); // Replace with your desired date
final DateTime date2 = DateTime(2024, 1, 11); // Replace with another date
final DateTime date3 = DateTime(2024, 1, 12); // Replace with yet another date
final String question1 = generator.getQuestionByDate(date1);
final String question2 = generator.getQuestionByDate(date2);
final String question3 = generator.getQuestionByDate(date3);
// Assert that the generated questions for different dates are not the same
expect(question1, equals(question2));
expect(question2, equals(question3));
expect(question3, equals(question1));
});
test('getQuestionByDate should return the same question for the same date', () {
final QuestionGenerator generator = QuestionGenerator();
// Test with the same date
final DateTime date = DateTime(2024, 1, 10); // Replace with your desired date
final String question1 = generator.getQuestionByDate(date);
final String question2 = generator.getQuestionByDate(date);
// Assert that the generated questions for the same date are the same
expect(question1, equals(question2));
});
});
}