2019-12-21 19:00:07 +01:00
|
|
|
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later
|
|
|
|
|
|
|
|
package org.schabi.newpipe.extractor.services.bandcamp;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
|
|
import org.junit.jupiter.api.Test;
|
2021-01-15 21:55:40 +01:00
|
|
|
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
2019-12-21 19:00:07 +01:00
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
|
|
import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
2020-04-20 21:55:35 +02:00
|
|
|
import static org.schabi.newpipe.extractor.ServiceList.Bandcamp;
|
2019-12-21 19:00:07 +01:00
|
|
|
|
|
|
|
public class BandcampSearchQueryHandlerFactoryTest {
|
|
|
|
|
|
|
|
static BandcampSearchQueryHandlerFactory searchQuery;
|
|
|
|
|
2021-12-27 21:08:08 +01:00
|
|
|
@BeforeAll
|
2019-12-21 19:00:07 +01:00
|
|
|
public static void setUp() {
|
|
|
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
|
|
|
|
2020-04-20 21:55:35 +02:00
|
|
|
searchQuery = (BandcampSearchQueryHandlerFactory) Bandcamp
|
2019-12-21 19:00:07 +01:00
|
|
|
.getSearchQHFactory();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testEncoding() throws ParsingException {
|
|
|
|
// Note: this isn't exactly as bandcamp does it (it wouldn't encode '!'), but both works
|
2019-12-22 13:51:17 +01:00
|
|
|
assertEquals("https://bandcamp.com/search?q=hello%21%22%C2%A7%24%25%26%2F%28%29%3D&page=1", searchQuery.getUrl("hello!\"§$%&/()="));
|
2019-12-21 19:00:07 +01:00
|
|
|
// Note: bandcamp uses %20 instead of '+', but both works
|
2019-12-22 13:51:17 +01:00
|
|
|
assertEquals("https://bandcamp.com/search?q=search+query+with+spaces&page=1", searchQuery.getUrl("search query with spaces"));
|
2019-12-21 19:00:07 +01:00
|
|
|
}
|
|
|
|
}
|