Merge pull request #955 from bryceknz/fix/951-test-expectations
Fix media version label tests
This commit is contained in:
@@ -8,14 +8,12 @@ int? bitrateKbpsFromBps(int? bps) {
|
||||
return (bps / 1000).round();
|
||||
}
|
||||
|
||||
final _videoResolution = RegExp(r'^(\d+)(k?)$', caseSensitive: false);
|
||||
final _numericVideoResolution = RegExp(r'^\d+$');
|
||||
|
||||
/// Plex uses numeric heights for SD/HD and values like `4k`/`8k` for UHD+.
|
||||
/// Plex may return numeric heights (`1080`) or named resolution labels (`sd`, `4k`).
|
||||
String _videoResolutionDisplayLabel(String resolution) {
|
||||
final value = resolution.trim();
|
||||
final match = _videoResolution.firstMatch(value);
|
||||
if (match == null) return value;
|
||||
return match.group(2)!.isEmpty ? '${match.group(1)}p' : '${match.group(1)}K';
|
||||
return _numericVideoResolution.hasMatch(value) ? '${value}p' : value.toUpperCase();
|
||||
}
|
||||
|
||||
/// A single media variant available for an item — represents one quality level
|
||||
|
||||
@@ -118,7 +118,7 @@ void main() {
|
||||
for (final resolution in ['8k', '8K']) {
|
||||
expect(displayLabel(resolution), startsWith('8K '));
|
||||
}
|
||||
expect(displayLabel('sd'), startsWith('sd '));
|
||||
expect(displayLabel('sd'), startsWith('SD '));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user