Default languages with env & langcodes typed (#94)

This commit is contained in:
David
2022-02-24 19:53:31 +01:00
committed by GitHub
parent 5e4db73a9f
commit 5856776785
15 changed files with 89 additions and 50 deletions

View File

@@ -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);