2024-06-03 16:35:33 +02:00
|
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
2024-05-27 14:40:46 +02:00
|
|
|
import 'package:cofounderella/utils/helper.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
group('getCompoundId', () {
|
|
|
|
test('returns correct compound ID for a sorted list', () {
|
|
|
|
List<String> ids = ['id3', 'id1', 'id2'];
|
|
|
|
String result = getCompoundId(ids);
|
|
|
|
expect(result, 'id1_id2_id3');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('returns correct compound ID for an already sorted list', () {
|
|
|
|
List<String> ids = ['id1', 'id2', 'id3'];
|
|
|
|
String result = getCompoundId(ids);
|
|
|
|
expect(result, 'id1_id2_id3');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('returns correct compound ID for a single element list', () {
|
|
|
|
List<String> ids = ['id1'];
|
|
|
|
String result = getCompoundId(ids);
|
|
|
|
expect(result, 'id1');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('returns correct compound ID for empty elements', () {
|
2024-06-03 16:35:33 +02:00
|
|
|
List<String> ids = ['id1', '', 'id2', ''];
|
2024-05-27 14:40:46 +02:00
|
|
|
String result = getCompoundId(ids);
|
|
|
|
expect(result, '__id1_id2');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('returns correct compound ID for an empty list', () {
|
|
|
|
List<String> ids = [];
|
|
|
|
String result = getCompoundId(ids);
|
|
|
|
expect(result, '');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-06-03 16:35:33 +02:00
|
|
|
group('formatTimestamp', () {
|
|
|
|
test('formatTimestamp returns the expected formatted date for 01.01.1970',
|
|
|
|
() {
|
|
|
|
Timestamp timestamp = Timestamp.fromDate(DateTime(1970, 1, 1, 23, 59));
|
|
|
|
String expectedFormattedDate = 'Thu, 1. Jan. 1970 23:59';
|
|
|
|
String formattedDate = formatTimestamp(timestamp);
|
|
|
|
expect(formattedDate, expectedFormattedDate);
|
|
|
|
});
|
|
|
|
|
|
|
|
test(
|
|
|
|
'formatTimestamp returns the expected formatted date for another timestamp',
|
|
|
|
() {
|
|
|
|
Timestamp timestamp = Timestamp.fromDate(DateTime(2023, 8, 15));
|
|
|
|
String expectedFormattedDate = 'Tue, 15. Aug. 2023 00:00';
|
|
|
|
String formattedDate = formatTimestamp(timestamp);
|
|
|
|
expect(formattedDate, expectedFormattedDate);
|
|
|
|
});
|
|
|
|
});
|
2024-05-27 14:40:46 +02:00
|
|
|
}
|