refactor: Projektstruktur in app/ und backend/ aufgeteilt
This commit is contained in:
86
app/test/views/cargo_items_view_test.dart
Normal file
86
app/test/views/cargo_items_view_test.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:votianlt_app/cargo_items_view.dart';
|
||||
import 'package:votianlt_app/models/delivery_station.dart';
|
||||
import 'package:votianlt_app/models/tasks/confirmation_task.dart';
|
||||
|
||||
void main() {
|
||||
group('deliveryStationCardBackgroundColor', () {
|
||||
DeliveryStation buildStation(List<ConfirmationTask> tasks) {
|
||||
return DeliveryStation(
|
||||
stationOrder: 0,
|
||||
company: 'ACME',
|
||||
salutation: null,
|
||||
firstName: 'Max',
|
||||
lastName: 'Mustermann',
|
||||
phone: '12345',
|
||||
street: 'Musterstrasse',
|
||||
houseNumber: '1',
|
||||
addressAddition: '',
|
||||
zip: '12345',
|
||||
city: 'Berlin',
|
||||
deliveryDate: '2026-03-10',
|
||||
deliveryTime: '10:00',
|
||||
tasks: tasks,
|
||||
);
|
||||
}
|
||||
|
||||
ConfirmationTask buildTask(String id, {bool completed = false}) {
|
||||
return ConfirmationTask(
|
||||
id: id,
|
||||
jobId: 'job-1',
|
||||
buttonText: 'Bestaetigen',
|
||||
completed: completed,
|
||||
);
|
||||
}
|
||||
|
||||
test('returns light green when all station tasks are completed', () {
|
||||
final station = buildStation([
|
||||
buildTask('task-1', completed: true),
|
||||
buildTask('task-2', completed: true),
|
||||
]);
|
||||
|
||||
final color = deliveryStationCardBackgroundColor(station, const {});
|
||||
|
||||
expect(color, Colors.green[50]);
|
||||
});
|
||||
|
||||
test('returns null when only some tasks are completed', () {
|
||||
final station = buildStation([
|
||||
buildTask('task-1', completed: true),
|
||||
buildTask('task-2'),
|
||||
]);
|
||||
|
||||
final color = deliveryStationCardBackgroundColor(station, const {});
|
||||
|
||||
expect(color, isNull);
|
||||
});
|
||||
|
||||
test('returns null when no tasks are completed', () {
|
||||
final station = buildStation([buildTask('task-1'), buildTask('task-2')]);
|
||||
|
||||
final color = deliveryStationCardBackgroundColor(station, const {});
|
||||
|
||||
expect(color, isNull);
|
||||
});
|
||||
|
||||
test('returns null when station has no tasks', () {
|
||||
final station = buildStation(const []);
|
||||
|
||||
final color = deliveryStationCardBackgroundColor(station, const {});
|
||||
|
||||
expect(color, isNull);
|
||||
});
|
||||
|
||||
test('prefers local task status over incomplete task payload', () {
|
||||
final station = buildStation([buildTask('task-1'), buildTask('task-2')]);
|
||||
|
||||
final color = deliveryStationCardBackgroundColor(station, const {
|
||||
'task-1': true,
|
||||
'task-2': true,
|
||||
});
|
||||
|
||||
expect(color, Colors.green[50]);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user