From 486c92ad2e7a061536ccaff73eaf2a9e07e62750 Mon Sep 17 00:00:00 2001 From: Simon Varney Date: Thu, 20 Jun 2024 14:25:44 +0200 Subject: [PATCH 1/3] Add missing titles (from Zuora-api) --- config/print-mapping.js | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/config/print-mapping.js b/config/print-mapping.js index 0febc82..8b60250 100644 --- a/config/print-mapping.js +++ b/config/print-mapping.js @@ -11,6 +11,10 @@ const productConfig = { diTitle: "Dagens Nyheter", complaintSenderId: "1160", }, + { + title: "kp", + productName: "Kamratposten", + }, ], di: [ { @@ -57,6 +61,10 @@ const productConfig = { diCustomerSystem: "EXPA", diTitle: "EX Expressen", }, + { + title: "sportexpressen", + productName: "SportExpressen", + }, { title: "gt", tsCode: "0760", @@ -459,6 +467,14 @@ const productConfig = { productName: "Bärgslagsbladet", diCustomerSystem: "BARG", }, + { + title: "bblat", + productName: "Bbl/AT", + }, + { + title: "bp", + productName: "Bandypuls", + }, { title: "bt", alternativeTitles: [ "borlangetidning" ], @@ -509,6 +525,10 @@ const productConfig = { productName: "Falu-Kuriren", diCustomerSystem: "", }, + { + title: "frp", + productName: "Folkracepuls", + }, { title: "gd", alternativeTitles: [ "gefledagblad" ], @@ -529,6 +549,10 @@ const productConfig = { productName: "Helsingborgs Dagblad", diCustomerSystem: "HELD", }, + { + title: "hp", + productName: "Hockeypuls", + }, { title: "ht", alternativeTitles: [ "hudiksvalsstidning", "hudiksvallstidning" ], @@ -539,6 +563,10 @@ const productConfig = { productName: "Hudiksvalls Tidning", diCustomerSystem: "", }, + { + title: "jnytt", + productName: "Jnytt", + }, { title: "jp", alternativeTitles: [ "jonkopingsposten" ], @@ -619,6 +647,10 @@ const productConfig = { productName: "Nerikes Allehanda", diCustomerSystem: "NAA", }, + { + title: "nio", + productName: "Nu i Österåker", + }, { title: "nst", alternativeTitles: [ "norraskanetidning" ], @@ -659,6 +691,10 @@ const productConfig = { productName: "Nynäshamns Posten", diCustomerSystem: "NYP", }, + { + title: "nvp", + productName: "Nacka Värmdö Posten", + }, { title: "oa", alternativeTitles: [ "ornskoldsvikallehanda" ], @@ -739,6 +775,10 @@ const productConfig = { productName: "Söderhamns Kuriren", diCustomerSystem: "", }, + { + title: "sn", + productName: "Skövde Nyheter", + }, { title: "sdt", alternativeTitles: [ "sodradalarnestidning" ], @@ -799,6 +839,10 @@ const productConfig = { productName: "Tranås Tidning", diCustomerSystem: "TTI", }, + { + title: "trp", + productName: "Tranås-Posten", + }, { title: "vlt", alternativeTitles: [ "vastmanlandslanstidning" ], From fa14074779bbd5804fd8c3518484d1cf1eb9f319 Mon Sep 17 00:00:00 2001 From: Simon Varney Date: Thu, 20 Jun 2024 14:26:39 +0200 Subject: [PATCH 2/3] Rename print-mapping to product-mapping --- config/{print-mapping.js => product-mapping.js} | 0 lib/titles.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename config/{print-mapping.js => product-mapping.js} (100%) diff --git a/config/print-mapping.js b/config/product-mapping.js similarity index 100% rename from config/print-mapping.js rename to config/product-mapping.js diff --git a/lib/titles.js b/lib/titles.js index ef01913..4dfca6e 100644 --- a/lib/titles.js +++ b/lib/titles.js @@ -1,4 +1,4 @@ -import productConfig from "../config/print-mapping.js"; +import productConfig from "../config/product-mapping.js"; const postalDeliveryAllowedTitles = [ "dn", "paf", "plg" ]; From c4ef89dc4e6be9da107ec2cd825339a0b92ae747 Mon Sep 17 00:00:00 2001 From: Simon Varney Date: Sat, 22 Jun 2024 08:13:44 +0200 Subject: [PATCH 3/3] Functions to return both print and all titles --- lib/titles.js | 12 +++++++++++- test/unit/titles-get-all-print-titles-test.js | 11 ----------- test/unit/titles-get-all-titles-test.js | 15 +++++++++++++++ ....js => titles-get-titles-by-namespace-test.js} | 12 +++++++++--- 4 files changed, 35 insertions(+), 15 deletions(-) delete mode 100644 test/unit/titles-get-all-print-titles-test.js create mode 100644 test/unit/titles-get-all-titles-test.js rename test/unit/{titles-get-all-print-titles-by-namespace-test.js => titles-get-titles-by-namespace-test.js} (58%) diff --git a/lib/titles.js b/lib/titles.js index 4dfca6e..cec98f0 100644 --- a/lib/titles.js +++ b/lib/titles.js @@ -28,10 +28,18 @@ Object.keys(productConfig).forEach((namespace) => { }); function getAllPrintTitles() { - return productMapping.filter((pm) => pm.title).map((pm) => pm.title); + return productMapping.filter((pm) => pm.tsCode).map((pm) => pm.title); } function getPrintTitlesByNamespace(namespace) { + return productConfig[namespace].filter((pm) => pm.tsCode).map((pm) => pm.title).filter((t) => t); +} + +function getAllTitles() { + return productMapping.filter((pm) => pm.title).map((pm) => pm.title); +} + +function getTitlesByNamespace(namespace) { return productConfig[namespace].map((pm) => pm.title).filter((t) => t); } @@ -39,6 +47,8 @@ export { postalDeliveryAllowed, getAllPrintTitles, getPrintTitlesByNamespace, + getAllTitles, + getTitlesByNamespace, productMapping, productConfig, }; diff --git a/test/unit/titles-get-all-print-titles-test.js b/test/unit/titles-get-all-print-titles-test.js deleted file mode 100644 index 09aeedb..0000000 --- a/test/unit/titles-get-all-print-titles-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { getAllPrintTitles, productMapping } from "../../lib/titles.js"; - -describe("getAllPrintTitles", () => { - describe("returns all titles", () => { - it("should return all titles", () => { - const allTitles = getAllPrintTitles(); - const allTitlesFromConfig = productMapping.filter((pm) => pm.title).map((pm) => pm.title); - allTitles.should.eql(allTitlesFromConfig); - }); - }); -}); diff --git a/test/unit/titles-get-all-titles-test.js b/test/unit/titles-get-all-titles-test.js new file mode 100644 index 0000000..a938528 --- /dev/null +++ b/test/unit/titles-get-all-titles-test.js @@ -0,0 +1,15 @@ +import { getAllTitles, getAllPrintTitles, productMapping } from "../../lib/titles.js"; + +describe("get titles", () => { + it("should return all titles", () => { + const allTitles = getAllTitles(); + const allTitlesFromConfig = productMapping.filter((pm) => pm.title).map((pm) => pm.title); + allTitles.should.eql(allTitlesFromConfig); + }); + + it("should return all print titles", () => { + const allTitles = getAllPrintTitles(); + const allTitlesFromConfig = productMapping.filter((pm) => pm.tsCode).map((pm) => pm.title); + allTitles.should.eql(allTitlesFromConfig); + }); +}); diff --git a/test/unit/titles-get-all-print-titles-by-namespace-test.js b/test/unit/titles-get-titles-by-namespace-test.js similarity index 58% rename from test/unit/titles-get-all-print-titles-by-namespace-test.js rename to test/unit/titles-get-titles-by-namespace-test.js index acf2b45..a5fa4bd 100644 --- a/test/unit/titles-get-all-print-titles-by-namespace-test.js +++ b/test/unit/titles-get-titles-by-namespace-test.js @@ -1,4 +1,4 @@ -import { getPrintTitlesByNamespace, productConfig } from "../../lib/titles.js"; +import { getTitlesByNamespace, getPrintTitlesByNamespace, productConfig } from "../../lib/titles.js"; const namespaceSafety = [ { namespace: "dn", text: "DN" }, @@ -9,14 +9,20 @@ const namespaceSafety = [ { namespace: "gotamedia", text: "Gota Media" }, ]; -describe("getTitlesByNamespace", () => { +describe("get titles by namespace", () => { for (const n of namespaceSafety) { describe(n.text, () => { it(`should return all titles in namespace: ${n.namespace}`, () => { - const titles = getPrintTitlesByNamespace(n.namespace); + const titles = getTitlesByNamespace(n.namespace); const titlesFromConfig = productConfig[n.namespace].map((pm) => pm.title).filter((t) => t); titles.should.eql(titlesFromConfig); }); + + it(`should return all print titles in namespace: ${n.namespace}`, () => { + const titles = getPrintTitlesByNamespace(n.namespace); + const titlesFromConfig = productConfig[n.namespace].filter((t) => t.tsCode).map((pm) => pm.title).filter((t) => t); + titles.should.eql(titlesFromConfig); + }); }); } });