Files
neomovies-mobile/test/providers/downloads_provider_test.dart
factory-droid[bot] 39f311d02e fix: Improve GitHub Actions workflows and add comprehensive tests
GitHub Actions improvements:
- Fix release workflow to prevent draft releases on new workflow runs
- Add automatic deletion of previous releases with same tag
- Improve test workflow with torrent-engine-downloads branch support
- Update Flutter version and add code generation step
- Add Android lint checks and debug APK builds
- Remove emoji from all workflow outputs for cleaner logs
- Add make_latest flag for proper release versioning

Test improvements:
- Add comprehensive unit tests for TorrentInfo model
- Add tests for FilePriority enum with comparison operators
- Add DownloadsProvider tests for utility methods
- Add widget tests for UI components and interactions
- Test video file detection and main file selection
- Test torrent state detection (downloading, paused, completed)
- Test byte formatting for file sizes and speeds

All tests validate the torrent downloads functionality
and ensure proper integration with Android engine.
2025-10-03 07:07:15 +00:00

40 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter_test/flutter_test.dart';
import 'package:neomovies_mobile/presentation/providers/downloads_provider.dart';
void main() {
group('DownloadsProvider', () {
late DownloadsProvider provider;
setUp(() {
provider = DownloadsProvider();
});
tearDown(() {
provider.dispose();
});
test('initial state is correct', () {
expect(provider.torrents, isEmpty);
expect(provider.isLoading, isFalse);
expect(provider.error, isNull);
});
test('formatSpeed formats bytes correctly', () {
expect(provider.formatSpeed(1024), equals('1.0KB/s'));
expect(provider.formatSpeed(1048576), equals('1.0MB/s'));
expect(provider.formatSpeed(512), equals('512B/s'));
expect(provider.formatSpeed(2048000), equals('2.0MB/s'));
});
test('formatDuration formats duration correctly', () {
expect(provider.formatDuration(Duration(seconds: 30)), equals('30с'));
expect(provider.formatDuration(Duration(minutes: 2, seconds: 30)), equals('2м 30с'));
expect(provider.formatDuration(Duration(hours: 1, minutes: 30, seconds: 45)), equals('1ч 30м 45с'));
expect(provider.formatDuration(Duration(hours: 2)), equals('2ч 0м 0с'));
});
test('provider implements ChangeNotifier', () {
expect(provider, isA<ChangeNotifier>());
});
});
}