Text to Speech (#2)
* Initial TTS scrapping implemented * Audio & copy buttons added * TTS langs mapping fix * Webkit audio api fix * Added TTS-related testing * Last tweaks
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { htmlRes, resolveFetchWith } from "../commonUtils";
|
||||
import faker from "faker";
|
||||
import { googleScrape, extractSlug } from "../../utils/translate";
|
||||
import { googleScrape, extractSlug, textToSpeechScrape } from "../../utils/translate";
|
||||
|
||||
const source = faker.random.locale();
|
||||
const target = faker.random.locale();
|
||||
@@ -65,3 +65,21 @@ describe("extractSlug", () => {
|
||||
expect(extractSlug(array)).toStrictEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("textToSpeechScrape", () => {
|
||||
it("returns an array on successful request", async () => {
|
||||
resolveFetchWith({ status: 200 });
|
||||
expect(await textToSpeechScrape(target, query)).toEqual(expect.any(Array));
|
||||
});
|
||||
|
||||
it("returns 'null' on request error", async () => {
|
||||
const status = faker.random.number({ min: 400, max: 499 });
|
||||
resolveFetchWith({ status });
|
||||
expect(await textToSpeechScrape(target, query)).toBeNull();
|
||||
});
|
||||
|
||||
it("returns 'null' on network error", async () => {
|
||||
fetchMock.mockRejectOnce();
|
||||
expect(await textToSpeechScrape(target, query)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user