mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
modify generateChartColors() test cases to use _iterator_ instead of toList() since it's been used in the original code.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
- Hanaa Allohibi - <https://github.com/hn-n>
|
||||
- Shey Alnasrawi - <https://github.com/Milksheyke>
|
||||
- Costas Korai - <https://github.com/watcher6280>
|
||||
- Bassam Mutairi - <https://github.com/mutairibassam>
|
||||
|
||||
## Translators
|
||||
|
||||
|
||||
@@ -3,34 +3,76 @@ import 'package:wger/helpers/colors.dart';
|
||||
|
||||
void main() {
|
||||
group('generateChartColors', () {
|
||||
test('should generate 3 colors for 3 items', () {
|
||||
final colors = generateChartColors(3).toList();
|
||||
expect(colors, LIST_OF_COLORS3);
|
||||
test('should generate 3 colors for 3 items using iterator', () {
|
||||
final iterator = generateChartColors(3).iterator;
|
||||
final expectedColors = LIST_OF_COLORS3.iterator;
|
||||
|
||||
while (iterator.moveNext() && expectedColors.moveNext()) {
|
||||
expect(iterator.current, equals(expectedColors.current));
|
||||
}
|
||||
|
||||
expect(iterator.moveNext(), isFalse);
|
||||
expect(expectedColors.moveNext(), isFalse);
|
||||
});
|
||||
|
||||
test('should generate 5 colors for 5 items', () {
|
||||
final colors = generateChartColors(5).toList();
|
||||
expect(colors, LIST_OF_COLORS5);
|
||||
test('should generate 5 colors for 5 items using iterator', () {
|
||||
final iterator = generateChartColors(5).iterator;
|
||||
final expectedColors = LIST_OF_COLORS5.iterator;
|
||||
|
||||
while (iterator.moveNext() && expectedColors.moveNext()) {
|
||||
expect(iterator.current, equals(expectedColors.current));
|
||||
}
|
||||
|
||||
expect(iterator.moveNext(), isFalse);
|
||||
expect(expectedColors.moveNext(), isFalse);
|
||||
});
|
||||
|
||||
test('should generate 8 colors for 8 items', () {
|
||||
final colors = generateChartColors(8).toList();
|
||||
expect(colors, LIST_OF_COLORS8);
|
||||
test('should generate 8 colors for 8 items using iterator', () {
|
||||
final iterator = generateChartColors(8).iterator;
|
||||
final expectedColors = LIST_OF_COLORS8.iterator;
|
||||
|
||||
while (iterator.moveNext() && expectedColors.moveNext()) {
|
||||
expect(iterator.current, equals(expectedColors.current));
|
||||
}
|
||||
|
||||
expect(iterator.moveNext(), isFalse);
|
||||
expect(expectedColors.moveNext(), isFalse);
|
||||
});
|
||||
|
||||
test('should generate 8 colors for more than 8 items', () {
|
||||
final colors = generateChartColors(10).toList();
|
||||
expect(colors, LIST_OF_COLORS8);
|
||||
test('should generate 8 colors for more than 8 items using iterator', () {
|
||||
final iterator = generateChartColors(10).iterator;
|
||||
final expectedColors = LIST_OF_COLORS8.iterator;
|
||||
|
||||
while (iterator.moveNext() && expectedColors.moveNext()) {
|
||||
expect(iterator.current, equals(expectedColors.current));
|
||||
}
|
||||
|
||||
expect(iterator.moveNext(), isFalse);
|
||||
expect(expectedColors.moveNext(), isFalse);
|
||||
});
|
||||
|
||||
test('should generate 8 colors for 0 items', () {
|
||||
final colors = generateChartColors(0).toList();
|
||||
expect(colors, LIST_OF_COLORS3);
|
||||
test('should generate 8 colors for 0 items using iterator', () {
|
||||
final iterator = generateChartColors(0).iterator;
|
||||
final expectedColors = LIST_OF_COLORS3.iterator;
|
||||
|
||||
while (iterator.moveNext() && expectedColors.moveNext()) {
|
||||
expect(iterator.current, equals(expectedColors.current));
|
||||
}
|
||||
|
||||
expect(iterator.moveNext(), isFalse);
|
||||
expect(expectedColors.moveNext(), isFalse);
|
||||
});
|
||||
|
||||
test('should generate 8 colors for negative items', () {
|
||||
final colors = generateChartColors(-5).toList();
|
||||
expect(colors, LIST_OF_COLORS3);
|
||||
test('should generate 8 colors for negative items using iterator', () {
|
||||
final iterator = generateChartColors(-5).iterator;
|
||||
final expectedColors = LIST_OF_COLORS3.iterator;
|
||||
|
||||
while (iterator.moveNext() && expectedColors.moveNext()) {
|
||||
expect(iterator.current, equals(expectedColors.current));
|
||||
}
|
||||
|
||||
expect(iterator.moveNext(), isFalse);
|
||||
expect(expectedColors.moveNext(), isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user