2020-06-06 11:28:36 +02:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
group('Search', () {
|
|
|
|
YoutubeExplode yt;
|
|
|
|
setUp(() {
|
|
|
|
yt = YoutubeExplode();
|
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() {
|
|
|
|
yt.close();
|
|
|
|
});
|
|
|
|
|
2020-06-13 22:54:53 +02:00
|
|
|
test('SearchYouTubeVideosFromApi', () async {
|
2020-09-21 17:34:03 +02:00
|
|
|
var videos =
|
|
|
|
await yt.search.getVideos('undead corporation megalomania').toList();
|
2020-06-06 11:28:36 +02:00
|
|
|
expect(videos, isNotEmpty);
|
2020-09-11 12:12:41 +02:00
|
|
|
}, skip: 'Endpoint removed from YouTube');
|
2020-06-16 21:49:30 +02:00
|
|
|
|
|
|
|
//TODO: Find out why this fails
|
2020-06-13 22:54:53 +02:00
|
|
|
test('SearchYouTubeVideosFromPage', () async {
|
2020-06-14 11:54:30 +02:00
|
|
|
var searchQuery = await yt.search.queryFromPage('hello');
|
2020-06-13 22:54:53 +02:00
|
|
|
expect(searchQuery.content, isNotEmpty);
|
|
|
|
expect(searchQuery.relatedVideos, isNotEmpty);
|
|
|
|
expect(searchQuery.relatedQueries, isNotEmpty);
|
2020-06-16 21:49:30 +02:00
|
|
|
}, skip: 'This may fail on some environments');
|
2020-06-16 22:29:52 +02:00
|
|
|
|
|
|
|
test('SearchNoResults', () async {
|
|
|
|
var query =
|
|
|
|
await yt.search.queryFromPage('g;jghEOGHJeguEPOUIhjegoUEHGOGHPSASG');
|
|
|
|
expect(query.content, isEmpty);
|
|
|
|
expect(query.relatedQueries, isEmpty);
|
|
|
|
expect(query.relatedVideos, isEmpty);
|
|
|
|
var nextPage = await query.nextPage();
|
|
|
|
expect(nextPage, isNull);
|
|
|
|
});
|
2020-09-21 17:34:03 +02:00
|
|
|
|
|
|
|
test('SearchYouTubeVideosFromPageStream', () async {
|
|
|
|
var query = await yt.search.getVideosFromPage('hello').take(30).toList();
|
|
|
|
expect(query, hasLength(30));
|
|
|
|
});
|
2020-06-06 11:28:36 +02:00
|
|
|
});
|
|
|
|
}
|