diff --git a/src/lib/bookmarks.svelte.ts b/src/lib/bookmarks.svelte.ts index ddb2f272..60573967 100644 --- a/src/lib/bookmarks.svelte.ts +++ b/src/lib/bookmarks.svelte.ts @@ -211,7 +211,11 @@ export function getIsBookmarked( ctx: Pick, ): 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) => string } = diff --git a/tests/testUtils.ts b/tests/testUtils.ts index c20070ff..9851e271 100644 --- a/tests/testUtils.ts +++ b/tests/testUtils.ts @@ -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, + }, + }, +}; diff --git a/tests/unit/bookmarks/bookmarks.test.ts b/tests/unit/bookmarks/bookmarks.test.ts index 0266caa2..f96fdf20 100644 --- a/tests/unit/bookmarks/bookmarks.test.ts +++ b/tests/unit/bookmarks/bookmarks.test.ts @@ -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", @@ -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);