Skip to content
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
6 changes: 5 additions & 1 deletion src/lib/bookmarks.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ export function getIsBookmarked<T extends BookmarkType>(
ctx: Pick<Ctx, "profileConfig">,
): boolean {
const bookmarkId = formatBookmarkId[type](bookmarkData, ctx);
return bookmarks[type].some(({ id }) => id === bookmarkId);
return bookmarks[type].some(
(bookmark) =>
(!("profile" in bookmark) || bookmark.profile == ctx.profileConfig.id) &&
bookmark.id === bookmarkId,
);
}

export const bookmarkToString: { [T in BookmarkType]: (bookmarkData: BookmarkData<T>) => string } =
Expand Down
49 changes: 49 additions & 0 deletions tests/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,52 @@ export const exampleProfileConfig: ProfileConfig = {
},
},
};

export const exampleProfileConfig2: ProfileConfig = {
name: "Beispiel2",
id: "oebb",
lang: "de",
supportedLanguages: ["de"],
products: {
tram: {
name: "Straßenbahn",
},
suburban: {
name: "S-Bahn",
},
},
options: {
maxTransfers: {
name: "Mindest-Umsteigezeit",
possibleValues: [0, 1, 2, 3, 4, 5, -1],
defaultValue: -1,
optionNames: {
"0": {
name: "nur Direkt-Verbindungen",
},
"1": {
name: "1",
},
"2": {
name: "2",
},
"3": {
name: "3",
},
"4": {
name: "4",
},
"5": {
name: "5",
},
"-1": {
name: "beliebig",
},
},
},
accessible: {
name: "Barrierefreiheit",
defaultValue: false,
},
},
};
5 changes: 4 additions & 1 deletion tests/unit/bookmarks/bookmarks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
initBookmarks,
removeBookmark,
} from "$lib/bookmarks.svelte";
import { exampleProfileConfig } from "../../testUtils";
import { exampleProfileConfig, exampleProfileConfig2 } from "../../testUtils";

const sunBookmarkData: BookmarkData<"location"> = {
id: "sun",
Expand Down Expand Up @@ -72,6 +72,9 @@ describe.sequential("add and remove bookmarks", () => {
expect(
getIsBookmarked("location", sunBookmark, { profileConfig: exampleProfileConfig }),
).toBe(true);
expect(
getIsBookmarked("location", sunBookmark, { profileConfig: exampleProfileConfig2 }),
).toBe(false);
expect(
getIsBookmarked("location", moonBookmark, { profileConfig: exampleProfileConfig }),
).toBe(false);
Expand Down
Loading