Add search from page tests.
This commit is contained in:
parent
8372726a65
commit
a9275af1e2
|
@ -143,7 +143,7 @@ class YoutubeHttpClient extends http.BaseClient {
|
|||
request.headers[key] = _defaultHeaders[key];
|
||||
}
|
||||
});
|
||||
// print('Request: $request');
|
||||
// print('Request: $request');
|
||||
// print('Stack:\n${StackTrace.current}');
|
||||
return _httpClient.send(request);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
///
|
||||
/// This i can either be a [SearchVideo] or [SearchPlaylist]
|
||||
abstract class BaseSearchContent {
|
||||
///
|
||||
const BaseSearchContent();
|
||||
|
|
|
@ -17,7 +17,26 @@ void main() {
|
|||
expect(videos, isNotEmpty);
|
||||
});
|
||||
|
||||
test('Search a youtube videos from the search page', () async {
|
||||
test('Search a youtube video from the search page', () async {
|
||||
var videos = await yt.search
|
||||
.getVideosFromPage('hello')
|
||||
.where((e) => e is SearchVideo) // Take only the videos.
|
||||
.cast<SearchVideo>()
|
||||
.take(10) // Take on 10 results.
|
||||
.toList();
|
||||
expect(videos, hasLength(10));
|
||||
var video = videos.first;
|
||||
expect(video.videoId, isNotNull);
|
||||
|
||||
expect(video.videoTitle, isNotEmpty);
|
||||
expect(video.videoAuthor, isNotEmpty);
|
||||
expect(video.videoDescriptionSnippet, isNotEmpty);
|
||||
expect(video.videoDuration, isNotEmpty);
|
||||
expect(video.videoViewCount, greaterThan(0));
|
||||
expect(video.videoThumbnails, isNotEmpty);
|
||||
});
|
||||
|
||||
test('Search a youtube videos from the search page - old', () async {
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
var searchQuery = await yt.search.queryFromPage('hello');
|
||||
expect(searchQuery.content, isNotEmpty);
|
||||
|
@ -25,7 +44,7 @@ void main() {
|
|||
expect(searchQuery.relatedQueries, isNotEmpty);
|
||||
}, skip: 'Not supported anymore');
|
||||
|
||||
test('Search with no results', () async {
|
||||
test('Search with no results - old', () async {
|
||||
var query =
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
await yt.search.queryFromPage('g;jghEOGHJeguEPOUIhjegoUEHGOGHPSASG');
|
||||
|
@ -36,7 +55,7 @@ void main() {
|
|||
expect(nextPage, isNull);
|
||||
});
|
||||
|
||||
test('Search youtube videos have thumbnails', () async {
|
||||
test('Search youtube videos have thumbnails - old', () async {
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
var searchQuery = await yt.search.queryFromPage('hello');
|
||||
expect(searchQuery.content.first, isA<SearchVideo>());
|
||||
|
@ -45,7 +64,7 @@ void main() {
|
|||
expect(video.videoThumbnails, isNotEmpty);
|
||||
});
|
||||
|
||||
test('Search youtube videos from search page (stream)', () async {
|
||||
test('Search youtube videos from search page (stream) - old', () async {
|
||||
var query = await yt.search.getVideosFromPage('hello').take(30).toList();
|
||||
expect(query, hasLength(30));
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue