Default languages with env & langcodes typed (#94)
This commit is contained in:
@@ -12,8 +12,8 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
describe("getStaticProps", () => {
|
||||
const source = faker.random.locale();
|
||||
const target = faker.random.locale();
|
||||
const source = "es";
|
||||
const target = "ca";
|
||||
const query = faker.random.words();
|
||||
|
||||
it("returns home on empty params", async () => {
|
||||
|
||||
@@ -50,7 +50,7 @@ it("returns translation triggering fetch", async () => {
|
||||
});
|
||||
|
||||
it("returns audio triggering fetch", async () => {
|
||||
const lang = faker.random.locale();
|
||||
const lang = "es";
|
||||
const text = faker.random.words();
|
||||
resolveFetchWith({ status: 200 });
|
||||
|
||||
@@ -93,7 +93,7 @@ it("returns null and throws on translation error", async () => {
|
||||
});
|
||||
|
||||
it("returns null and throws on audio error", async () => {
|
||||
const lang = faker.random.locale();
|
||||
const lang = "es";
|
||||
const text = faker.random.words();
|
||||
fetchMock.mockRejectOnce();
|
||||
|
||||
@@ -178,7 +178,7 @@ it("throws error on empty query in translation", async () => {
|
||||
});
|
||||
|
||||
it("throws error on empty lang or query in audio", async () => {
|
||||
const lang = faker.random.locale();
|
||||
const lang = "es";
|
||||
const text = faker.random.words();
|
||||
|
||||
const { errors: queryErrors } = await query({
|
||||
|
||||
@@ -7,8 +7,8 @@ beforeEach(() => {
|
||||
fetchMock.resetMocks();
|
||||
});
|
||||
|
||||
const source = faker.random.locale();
|
||||
const target = faker.random.locale();
|
||||
const source = "es";
|
||||
const target = "ca";
|
||||
const query = faker.random.words();
|
||||
const slug = [source, target, query];
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ describe("replaceBoth", () => {
|
||||
langType: LangType
|
||||
) => (
|
||||
Object.entries(checkObj[langType]).forEach(([code, replacement]) => {
|
||||
const res = replaceBoth(checkType, { source: "", target: "", [langType]: code })
|
||||
const res = replaceBoth(checkType, { source: "auto", target: "en", [langType]: code })
|
||||
expect(res[langType]).toBe(replacement);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -17,13 +17,13 @@ it("changes a field value", () => {
|
||||
it("changes all fields", () => {
|
||||
const query = faker.random.words();
|
||||
const state = {
|
||||
source: faker.random.locale(),
|
||||
target: faker.random.locale(),
|
||||
source: "zh",
|
||||
target: "zh_HANT",
|
||||
query,
|
||||
delayedQuery: query,
|
||||
translation: faker.random.words(),
|
||||
isLoading: faker.datatype.boolean()
|
||||
};
|
||||
} as const;
|
||||
|
||||
const res = langReducer(initialState, {
|
||||
type: Actions.SET_ALL,
|
||||
@@ -37,7 +37,7 @@ it("switches target on source change", () => {
|
||||
...initialState,
|
||||
source: "es",
|
||||
target: "ca"
|
||||
};
|
||||
} as const;
|
||||
|
||||
const res = langReducer(state, {
|
||||
type: Actions.SET_FIELD,
|
||||
@@ -57,7 +57,7 @@ it("switches the languages & the translations", () => {
|
||||
target: "ca",
|
||||
query: faker.random.words(),
|
||||
translation: faker.random.words()
|
||||
};
|
||||
} as const;
|
||||
|
||||
const res = langReducer(state, { type: Actions.SWITCH_LANGS });
|
||||
expect(res).toStrictEqual({
|
||||
@@ -75,7 +75,7 @@ it("resets the source while switching if they're the same", () => {
|
||||
...initialState,
|
||||
source: "eo",
|
||||
target: "eo"
|
||||
};
|
||||
} as const;
|
||||
|
||||
const res = langReducer(state, { type: Actions.SWITCH_LANGS });
|
||||
expect(res.source).toStrictEqual(initialState.source);
|
||||
|
||||
@@ -2,8 +2,8 @@ import { htmlRes, resolveFetchWith } from "@tests/commonUtils";
|
||||
import faker from "faker";
|
||||
import { googleScrape, extractSlug, textToSpeechScrape } from "@utils/translate";
|
||||
|
||||
const source = faker.random.locale();
|
||||
const target = faker.random.locale();
|
||||
const source = "es";
|
||||
const target = "ca";
|
||||
const query = faker.random.words();
|
||||
|
||||
describe("googleScrape", () => {
|
||||
|
||||
Reference in New Issue
Block a user