mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Added localize implementation along with its tests
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { default as PKPass } from "../lib/PKPass";
|
||||
import {
|
||||
default as PKPass,
|
||||
localizationSymbol,
|
||||
propsSymbol,
|
||||
} from "../lib/PKPass";
|
||||
|
||||
describe("PKPass", () => {
|
||||
describe("setBeacons", () => {
|
||||
@@ -389,4 +393,48 @@ describe("PKPass", () => {
|
||||
expect(passCP.transitType).toBeUndefined(); */
|
||||
});
|
||||
});
|
||||
|
||||
describe("localize", () => {
|
||||
const pass = new PKPass({}, {}, {});
|
||||
|
||||
it("should create a new language record inside class props", () => {
|
||||
pass.localize("en");
|
||||
|
||||
expect(pass[localizationSymbol]["en"]).toEqual({});
|
||||
});
|
||||
|
||||
it("should save some translations to be exported later", () => {
|
||||
pass.localize("it", {
|
||||
say_hi: "ciao",
|
||||
say_gb: "arrivederci",
|
||||
});
|
||||
|
||||
expect(pass[localizationSymbol]["it"]).toEqual({
|
||||
say_hi: "ciao",
|
||||
say_gb: "arrivederci",
|
||||
});
|
||||
});
|
||||
|
||||
it("should accept later translations and merge them with existing ones", () => {
|
||||
pass.localize("it", {
|
||||
say_good_morning: "buongiorno",
|
||||
say_good_evening: "buonasera",
|
||||
});
|
||||
|
||||
expect(pass[localizationSymbol]["it"]).toEqual({
|
||||
say_hi: "ciao",
|
||||
say_gb: "arrivederci",
|
||||
say_good_morning: "buongiorno",
|
||||
say_good_evening: "buonasera",
|
||||
});
|
||||
});
|
||||
|
||||
it("should delete a language and its all translations when null is passed as parameter", () => {
|
||||
pass.localize("it", null);
|
||||
pass.localize("en", null);
|
||||
|
||||
expect(pass[localizationSymbol]["it"]).toBeUndefined();
|
||||
expect(pass[localizationSymbol]["en"]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user