Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Add missing titles to product mapping #150

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions config/print-mapping.js → config/product-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const productConfig = {
diTitle: "Dagens Nyheter",
complaintSenderId: "1160",
},
{
title: "kp",
productName: "Kamratposten",
},
],
di: [
{
Expand Down Expand Up @@ -57,6 +61,10 @@ const productConfig = {
diCustomerSystem: "EXPA",
diTitle: "EX Expressen",
},
{
title: "sportexpressen",
productName: "SportExpressen",
},
{
title: "gt",
tsCode: "0760",
Expand Down Expand Up @@ -459,6 +467,14 @@ const productConfig = {
productName: "Bärgslagsbladet",
diCustomerSystem: "BARG",
},
{
title: "bblat",
productName: "Bbl/AT",
},
{
title: "bp",
productName: "Bandypuls",
},
{
title: "bt",
alternativeTitles: [ "borlangetidning" ],
Expand Down Expand Up @@ -509,6 +525,10 @@ const productConfig = {
productName: "Falu-Kuriren",
diCustomerSystem: "",
},
{
title: "frp",
productName: "Folkracepuls",
},
{
title: "gd",
alternativeTitles: [ "gefledagblad" ],
Expand All @@ -529,6 +549,10 @@ const productConfig = {
productName: "Helsingborgs Dagblad",
diCustomerSystem: "HELD",
},
{
title: "hp",
productName: "Hockeypuls",
},
{
title: "ht",
alternativeTitles: [ "hudiksvalsstidning", "hudiksvallstidning" ],
Expand All @@ -539,6 +563,10 @@ const productConfig = {
productName: "Hudiksvalls Tidning",
diCustomerSystem: "",
},
{
title: "jnytt",
productName: "Jnytt",
},
{
title: "jp",
alternativeTitles: [ "jonkopingsposten" ],
Expand Down Expand Up @@ -619,6 +647,10 @@ const productConfig = {
productName: "Nerikes Allehanda",
diCustomerSystem: "NAA",
},
{
title: "nio",
productName: "Nu i Österåker",
},
{
title: "nst",
alternativeTitles: [ "norraskanetidning" ],
Expand Down Expand Up @@ -659,6 +691,10 @@ const productConfig = {
productName: "Nynäshamns Posten",
diCustomerSystem: "NYP",
},
{
title: "nvp",
productName: "Nacka Värmdö Posten",
},
{
title: "oa",
alternativeTitles: [ "ornskoldsvikallehanda" ],
Expand Down Expand Up @@ -739,6 +775,10 @@ const productConfig = {
productName: "Söderhamns Kuriren",
diCustomerSystem: "",
},
{
title: "sn",
productName: "Skövde Nyheter",
},
{
title: "sdt",
alternativeTitles: [ "sodradalarnestidning" ],
Expand Down Expand Up @@ -799,6 +839,10 @@ const productConfig = {
productName: "Tranås Tidning",
diCustomerSystem: "TTI",
},
{
title: "trp",
productName: "Tranås-Posten",
},
{
title: "vlt",
alternativeTitles: [ "vastmanlandslanstidning" ],
Expand Down
14 changes: 12 additions & 2 deletions lib/titles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import productConfig from "../config/print-mapping.js";
import productConfig from "../config/product-mapping.js";

const postalDeliveryAllowedTitles = [ "dn", "paf", "plg" ];

Expand Down Expand Up @@ -28,17 +28,27 @@ 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);
}

export {
postalDeliveryAllowed,
getAllPrintTitles,
getPrintTitlesByNamespace,
getAllTitles,
getTitlesByNamespace,
productMapping,
productConfig,
};
11 changes: 0 additions & 11 deletions test/unit/titles-get-all-print-titles-test.js

This file was deleted.

15 changes: 15 additions & 0 deletions test/unit/titles-get-all-titles-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -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" },
Expand All @@ -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);
});
});
}
});
Loading