From 3f56cf9c23ba9e06e04c928273767b4c18fde1f2 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Mon, 12 Jun 2023 15:51:05 +0200 Subject: [PATCH] Starting to implement a proper library for OSM tags --- src/lib/osm/tags.test.ts | 11 +++++++++++ src/lib/osm/tags.ts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/lib/osm/tags.test.ts create mode 100644 src/lib/osm/tags.ts diff --git a/src/lib/osm/tags.test.ts b/src/lib/osm/tags.test.ts new file mode 100644 index 0000000..6a54167 --- /dev/null +++ b/src/lib/osm/tags.test.ts @@ -0,0 +1,11 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { getTagStatus } from './tags'; + +describe('The getTagStatus function', () => { + it('should return false/false for a tag that does NOT exist', () => { + expect(getTagStatus('whatever', {}, '', '')).toEqual({ + selected: false, + highlighted: false, + }); + }); +}); diff --git a/src/lib/osm/tags.ts b/src/lib/osm/tags.ts new file mode 100644 index 0000000..9d35719 --- /dev/null +++ b/src/lib/osm/tags.ts @@ -0,0 +1,31 @@ +interface TagStatus { + selected: boolean; + highlighted: boolean; +} + +interface TagFormatDefinition {} + +interface TagCategoryDefinitions { + [key: string]: TagFormatDefinition; +} + +interface TagActivityDefinitions { + [key: string]: TagCategoryDefinitions; +} + +interface TagDefinitions { + [key: string]: TagActivityDefinitions; +} + +export const getTagStatus = ( + tag: string, + definitions: TagDefinitions, + selectedKey: string, + highlightedKey: string +) => { + let status: TagStatus = { + selected: false, + highlighted: false, + }; + return status; +};