cofounderella/test/helper_test.dart

82 lines
2.4 KiB
Dart
Raw Normal View History

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', () {
List<String> ids = ['id1','','id2',''];
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, '');
});
});
group('equalContent', () {
test('returns true for lists with the same content in the same order', () {
List<dynamic> list1 = [1, 2, 3];
List<dynamic> list2 = [1, 2, 3];
bool result = equalContent(list1, list2);
expect(result, true);
});
test('returns true for lists with the same content in different orders',
() {
List<dynamic> list1 = [1, 2, 3];
List<dynamic> list2 = [3, 1, 2];
bool result = equalContent(list1, list2);
expect(result, true);
});
test('returns false for lists with different content', () {
List<dynamic> list1 = [1, 2, 3];
List<dynamic> list2 = [1, 2, 4];
bool result = equalContent(list1, list2);
expect(result, false);
});
test('returns false for lists with different lengths', () {
List<dynamic> list1 = [1, 2, 3];
List<dynamic> list2 = [1, 2];
bool result = equalContent(list1, list2);
expect(result, false);
});
test('returns true for empty lists', () {
List<dynamic> list1 = [];
List<dynamic> list2 = [];
bool result = equalContent(list1, list2);
expect(result, true);
});
test('returns false for one empty and one non-empty list', () {
List<dynamic> list1 = [];
List<dynamic> list2 = [1];
bool result = equalContent(list1, list2);
expect(result, false);
});
});
}