mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Added languages getter
This commit is contained in:
@@ -417,7 +417,7 @@ describe("PKPass", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("certificates setter", () => {
|
||||
describe("certificates", () => {
|
||||
it("should throw an error if certificates provided are not complete or invalid", () => {
|
||||
expect(() => {
|
||||
// @ts-expect-error
|
||||
@@ -583,6 +583,47 @@ describe("PKPass", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("languages", () => {
|
||||
it("should get updated when translations gets added through localize", () => {
|
||||
expect(pass.languages.length).toBe(0);
|
||||
expect(pass.languages).toEqual([]);
|
||||
|
||||
pass.localize("en", {
|
||||
buon_giorno: "Good Morning",
|
||||
buona_sera: "Good Evening",
|
||||
});
|
||||
|
||||
expect(pass.languages.length).toBe(1);
|
||||
expect(pass.languages).toEqual(["en"]);
|
||||
});
|
||||
|
||||
it("should get updated when translations are added through .addBuffer", () => {
|
||||
const validTranslationStringsEN = `
|
||||
/* Insert Element menu item */
|
||||
"Insert Element" = "Insert Element";
|
||||
/* Error string used for unknown error types. */
|
||||
"ErrorString_1" = "An unknown error occurred.";
|
||||
`;
|
||||
|
||||
pass.addBuffer(
|
||||
"en.lproj/pass.strings",
|
||||
Buffer.from(validTranslationStringsEN),
|
||||
);
|
||||
|
||||
const validTranslationStringsIT = `
|
||||
"Insert Element" = "Inserisci elemento";
|
||||
"ErrorString_1" = "Un errore sconosciuto è accaduto";
|
||||
`;
|
||||
|
||||
pass.addBuffer(
|
||||
"it.lproj/pass.strings",
|
||||
Buffer.from(validTranslationStringsIT),
|
||||
);
|
||||
|
||||
expect(pass.languages).toEqual(["en", "it"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("localize", () => {
|
||||
it("should fail throw if lang is not a string", () => {
|
||||
// @ts-expect-error
|
||||
|
||||
Reference in New Issue
Block a user