From f17daa0a457ea493e125f3d7f540bd773baa4d28 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sun, 17 Oct 2021 18:55:44 +0200 Subject: [PATCH] Movd another PKPass.from message to messages --- spec/PKPass.ts | 4 ++-- src/PKPass.ts | 2 +- src/messages.ts | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/PKPass.ts b/spec/PKPass.ts index 9704213..7955f80 100644 --- a/spec/PKPass.ts +++ b/spec/PKPass.ts @@ -960,12 +960,12 @@ describe("PKPass", () => { PKPass.from(), ).toBeRejectedWithError( TypeError, - "Cannot create PKPass from source: source is 'undefined'", + Messages.FROM.MISSING_SOURCE.replace("%s", "undefined"), ); await expectAsync(PKPass.from(null)).toBeRejectedWithError( TypeError, - "Cannot create PKPass from source: source is 'null'", + Messages.FROM.MISSING_SOURCE.replace("%s", "null"), ); }); diff --git a/src/PKPass.ts b/src/PKPass.ts index e8e5fdc..219f5b0 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -46,7 +46,7 @@ export default class PKPass extends Bundle { if (!source) { throw new TypeError( - `Cannot create PKPass from source: source is '${source}'`, + formatMessage(Messages.FROM.MISSING_SOURCE, source), ); } diff --git a/src/messages.ts b/src/messages.ts index fdf0f47..5a3749c 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -78,6 +78,10 @@ export const BUNDLE = { CLOSED: "Cannot add file. Bundle is closed.", } as const; +export const FROM = { + MISSING_SOURCE: "Cannot create PKPass from source: source is '%s'", +} as const; + export const PACK = { INVALID: "Cannot pack passes. Only PKPass instances allowed", } as const;