0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 07:10:44 -05:00

Updated localeService test after recent PR merge

Linted test file
This commit is contained in:
Dev 2024-05-20 09:54:40 +01:00
parent fcabd68dfc
commit 2fd5c918ce

View File

@ -22,13 +22,13 @@ describe("LocaleService", () =>
it("should return 'en' globals data when no desired locale found and display warning'", () => it("should return 'en' globals data when no desired locale found and display warning'", () =>
{ {
vi.spyOn(localeService, "getDesiredGameLocale").mockReturnValue({ vi.spyOn(localeService, "getDesiredGameLocale").mockReturnValue({
undefined undefined,
}); });
const warningLogSpy = vi.spyOn(localeService.logger, "warning") const warningLogSpy = vi.spyOn(localeService.logger, "warning");
const result = localeService.getLocaleDb(); const result = localeService.getLocaleDb();
expect(result).equals(localeService.localesTable.global.en); expect(result["54cb50c76803fa8b248b4571 FirstName"]).equals("Pavel Yegorovich");
expect(warningLogSpy).toHaveBeenCalledTimes(1); expect(warningLogSpy).toHaveBeenCalledTimes(1);
}); });
@ -47,14 +47,14 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformForClientLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformForClientLocale").mockReturnValue(
"desiredLocale" "desiredLocale",
); );
localeService.localeConfig.gameLocale = "system"; localeService.localeConfig.gameLocale = "system";
expect(localeService.getDesiredGameLocale()).toBe("desiredLocale"); expect(localeService.getDesiredGameLocale()).toBe("desiredLocale");
}); });
}) });
describe("getDesiredServerLocale", () => describe("getDesiredServerLocale", () =>
{ {
@ -69,14 +69,14 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformForServerLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformForServerLocale").mockReturnValue(
"desiredLocale" "desiredLocale",
); );
localeService.localeConfig.serverLocale = "system"; localeService.localeConfig.serverLocale = "system";
expect(localeService.getDesiredServerLocale()).toBe("desiredLocale"); expect(localeService.getDesiredServerLocale()).toBe("desiredLocale");
}); });
}) });
describe("getPlatformForServerLocale", () => describe("getPlatformForServerLocale", () =>
{ {
@ -84,7 +84,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
undefined undefined,
); );
const warningLogSpy = vi.spyOn(localeService.logger, "warning"); const warningLogSpy = vi.spyOn(localeService.logger, "warning");
@ -97,10 +97,10 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
{ baseName: "test_locale_that_doesnt_exist", language: "test_language" } { baseName: "test_locale_that_doesnt_exist", language: "test_language" },
); );
const warningLogSpy = vi.spyOn(localeService.logger, "warning") const warningLogSpy = vi.spyOn(localeService.logger, "warning");
expect(localeService.getPlatformForServerLocale()).toBe("en"); expect(localeService.getPlatformForServerLocale()).toBe("en");
expect(warningLogSpy).toHaveBeenCalledTimes(1); expect(warningLogSpy).toHaveBeenCalledTimes(1);
@ -113,9 +113,9 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
undefined undefined,
); );
const warningLogSpy = vi.spyOn(localeService.logger, "warning") const warningLogSpy = vi.spyOn(localeService.logger, "warning");
expect(localeService.getPlatformForClientLocale()).toBe("en"); expect(localeService.getPlatformForClientLocale()).toBe("en");
expect(warningLogSpy).toHaveBeenCalledTimes(1); expect(warningLogSpy).toHaveBeenCalledTimes(1);
@ -129,7 +129,7 @@ describe("LocaleService", () =>
return { baseName: "test_locale_that_doesnt_exist", language: "test_language" }; return { baseName: "test_locale_that_doesnt_exist", language: "test_language" };
}; };
const warningLogSpy = vi.spyOn(localeService.logger, "warning") const warningLogSpy = vi.spyOn(localeService.logger, "warning");
expect(localeService.getPlatformForClientLocale()).toBe("en"); expect(localeService.getPlatformForClientLocale()).toBe("en");
expect(warningLogSpy).toHaveBeenCalledTimes(1); expect(warningLogSpy).toHaveBeenCalledTimes(1);
@ -142,7 +142,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("en-US") new Intl.Locale("en-US"),
); );
expect(localeService.getPlatformForServerLocale()).toBe("en"); expect(localeService.getPlatformForServerLocale()).toBe("en");
@ -152,7 +152,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("ko-KR") new Intl.Locale("ko-KR"),
); );
expect(localeService.getPlatformForServerLocale()).toBe("ko"); expect(localeService.getPlatformForServerLocale()).toBe("ko");
@ -162,7 +162,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("pt-PT") new Intl.Locale("pt-PT"),
); );
expect(localeService.getPlatformForServerLocale()).toBe("pt-pt"); expect(localeService.getPlatformForServerLocale()).toBe("pt-pt");
@ -172,7 +172,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("pt-BR") new Intl.Locale("pt-BR"),
); );
expect(localeService.getPlatformForServerLocale()).toBe("pt-br"); expect(localeService.getPlatformForServerLocale()).toBe("pt-br");
@ -185,7 +185,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("en-US") new Intl.Locale("en-US"),
); );
expect(localeService.getPlatformForClientLocale()).toBe("en"); expect(localeService.getPlatformForClientLocale()).toBe("en");
@ -195,7 +195,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("ko-KR") new Intl.Locale("ko-KR"),
); );
expect(localeService.getPlatformForClientLocale()).toBe("kr"); expect(localeService.getPlatformForClientLocale()).toBe("kr");
@ -205,7 +205,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("es-MX") new Intl.Locale("es-MX"),
); );
expect(localeService.getPlatformForClientLocale()).toBe("es-mx"); expect(localeService.getPlatformForClientLocale()).toBe("es-mx");
@ -215,7 +215,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("cs-CZ") new Intl.Locale("cs-CZ"),
); );
expect(localeService.getPlatformForClientLocale()).toBe("cz"); expect(localeService.getPlatformForClientLocale()).toBe("cz");
@ -225,7 +225,7 @@ describe("LocaleService", () =>
{ {
// Override the get locale so we control what the input is // Override the get locale so we control what the input is
vi.spyOn(localeService, "getPlatformLocale").mockReturnValue( vi.spyOn(localeService, "getPlatformLocale").mockReturnValue(
new Intl.Locale("de-DE") new Intl.Locale("de-DE"),
); );
expect(localeService.getPlatformForClientLocale()).toBe("ge"); expect(localeService.getPlatformForClientLocale()).toBe("ge");