Optionally add tag to place photo
This commit is contained in:
38
tests/unit/utils/poi-category-matcher-test.js
Normal file
38
tests/unit/utils/poi-category-matcher-test.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { POI_CATEGORIES } from 'marco/utils/poi-categories';
|
||||
import {
|
||||
getMatchingPoiCategories,
|
||||
getMatchingPoiCategoryIds,
|
||||
} from 'marco/utils/poi-category-matcher';
|
||||
|
||||
module('Unit | Utility | poi-category-matcher', function () {
|
||||
test('matches multiple categories from OSM tags', function (assert) {
|
||||
const tags = { amenity: 'cafe' };
|
||||
const categoryIds = getMatchingPoiCategoryIds(tags, POI_CATEGORIES);
|
||||
|
||||
assert.ok(categoryIds.includes('restaurants'));
|
||||
assert.ok(categoryIds.includes('coffee'));
|
||||
});
|
||||
|
||||
test('supports semicolon-separated values', function (assert) {
|
||||
const tags = { amenity: 'cafe;bar' };
|
||||
const categoryIds = getMatchingPoiCategoryIds(tags, POI_CATEGORIES);
|
||||
|
||||
assert.ok(categoryIds.includes('coffee'));
|
||||
});
|
||||
|
||||
test('negative regex clause fails if any value matches', function (assert) {
|
||||
const tags = { amenity: 'cafe', cuisine: 'coffee;irish' };
|
||||
const categoryIds = getMatchingPoiCategoryIds(tags, POI_CATEGORIES);
|
||||
|
||||
assert.notOk(categoryIds.includes('restaurants'));
|
||||
});
|
||||
|
||||
test('presence clause matches when tag exists', function (assert) {
|
||||
const tags = { historic: 'castle' };
|
||||
const categories = getMatchingPoiCategories(tags, POI_CATEGORIES);
|
||||
const categoryIds = categories.map((category) => category.id);
|
||||
|
||||
assert.ok(categoryIds.includes('things-to-do'));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user