You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
44 lines
1.4 KiB
import 'package:eaimar/data/services/device_location_service.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('百炼 \${date}:年月日 星期 时:分', () {
|
|
expect(DeviceLocationService.dateText(DateTime(2026, 9, 25, 21, 5)),
|
|
'2026年9月25日 星期五 21:05');
|
|
expect(DeviceLocationService.dateText(DateTime(2026, 9, 27, 9, 0)),
|
|
'2026年9月27日 星期日 09:00');
|
|
});
|
|
|
|
test('百炼 \${location}:完整地址优先,否则省市区加街道,不带经纬度', () {
|
|
expect(
|
|
DeviceLocationService.formatPlaceText({
|
|
'province': '广东省',
|
|
'city': '深圳市',
|
|
'district': '福田区',
|
|
'street': '华强北路',
|
|
'address': '广东省深圳市福田区华强北路1002号',
|
|
'latitude': 22.5431,
|
|
'longitude': 114.0579,
|
|
}),
|
|
'广东省深圳市福田区华强北路1002号',
|
|
);
|
|
expect(
|
|
DeviceLocationService.formatPlaceText({
|
|
'province': '北京市',
|
|
'city': '北京市',
|
|
'district': '东城区',
|
|
'street': '王府井大街',
|
|
'address': '',
|
|
}),
|
|
'北京市东城区王府井大街',
|
|
);
|
|
expect(
|
|
DeviceLocationService.formatPlaceText({
|
|
'latitude': 22.54,
|
|
'longitude': 114.05,
|
|
}),
|
|
'未知',
|
|
);
|
|
expect(DeviceLocationService.formatPlaceText(null), '未知');
|
|
});
|
|
}
|
|
|