mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 16:03:02 +00:00
8fd46c4c18
Small requests from the discussions, each built end to end: planner and map (cycling mode, date first headings, clear a day, stay times per day, off-route stops, map lock, compact unplanned markers, pending stays, cable car, transit quick picks), places (location filter, category from OSM, open in maps, geo: link, image from an attachment, enrichment on file import, places near a pin, place name language, Amap first in China), lists and costs (packed counter, inherited sharing, Markdown to-dos, payment notes, bookings CSV, my plan PDF), sharing (unplanned places, travel only, without photos), journey (photo zoom, drafts, photo order, trip suggestion, day jump), atlas (region counter, region bucket list, places per country), vacay half company holidays, studio copy and paste plus the book's own layouts, and RESTORE_FROM_BACKUP for a first start restore.
54 lines
2.6 KiB
TypeScript
54 lines
2.6 KiB
TypeScript
// FE-PLANNER-CATGUESS-001 to FE-PLANNER-CATGUESS-006
|
|
import { describe, it, expect } from 'vitest'
|
|
import { guessCategoryId, kindOfResult } from './placeCategoryGuess'
|
|
|
|
const seeded = [
|
|
{ id: 1, name: 'Hotel', icon: '🏨' },
|
|
{ id: 2, name: 'Restaurant', icon: '🍽️' },
|
|
{ id: 3, name: 'Attraction', icon: '🏛️' },
|
|
{ id: 4, name: 'Shopping', icon: '🛍️' },
|
|
{ id: 5, name: 'Transport', icon: '🚌' },
|
|
{ id: 6, name: 'Activity', icon: '🎯' },
|
|
{ id: 7, name: 'Bar/Cafe', icon: '☕' },
|
|
{ id: 8, name: 'Beach', icon: '🏖️' },
|
|
{ id: 9, name: 'Nature', icon: '🌿' },
|
|
{ id: 10, name: 'Other', icon: '📍' },
|
|
]
|
|
|
|
describe('guessCategoryId', () => {
|
|
it('FE-PLANNER-CATGUESS-001: an OSM hotel lands in the Hotel category', () => {
|
|
expect(guessCategoryId({ category: 'hotel' }, seeded)).toBe(1)
|
|
expect(guessCategoryId({ category: 'guest_house' }, seeded)).toBe(1)
|
|
})
|
|
|
|
it('FE-PLANNER-CATGUESS-002: Google types are read in order, so a restaurant bar is still a bar', () => {
|
|
expect(guessCategoryId({ types: ['restaurant', 'food', 'point_of_interest'] }, seeded)).toBe(2)
|
|
expect(guessCategoryId({ types: ['bar', 'restaurant'] }, seeded)).toBe(7)
|
|
expect(guessCategoryId({ types: ['museum', 'tourist_attraction'] }, seeded)).toBe(3)
|
|
})
|
|
|
|
it('FE-PLANNER-CATGUESS-003: a shop and a station find their categories', () => {
|
|
expect(guessCategoryId({ category: 'shop_bakery' }, seeded)).toBe(7)
|
|
expect(guessCategoryId({ category: 'shop_clothes' }, seeded)).toBe(4)
|
|
expect(guessCategoryId({ types: ['train_station', 'transit_station'] }, seeded)).toBe(5)
|
|
})
|
|
|
|
it('FE-PLANNER-CATGUESS-004: renamed categories are still found, by a local name or their icon', () => {
|
|
expect(guessCategoryId({ category: 'hotel' }, [{ id: 42, name: 'Unterkunft', icon: 'X' }])).toBe(42)
|
|
expect(guessCategoryId({ category: 'hotel' }, [{ id: 43, name: 'Schlafen', icon: 'BedDouble' }])).toBe(43)
|
|
})
|
|
|
|
it('FE-PLANNER-CATGUESS-005: nothing to go on, or nothing that fits, leaves the field empty', () => {
|
|
expect(guessCategoryId({}, seeded)).toBeNull()
|
|
expect(guessCategoryId({ types: ['point_of_interest'] }, seeded)).toBeNull()
|
|
expect(guessCategoryId({ category: 'hotel' }, [{ id: 1, name: 'Food', icon: '🍴' }])).toBeNull()
|
|
})
|
|
|
|
it('FE-PLANNER-CATGUESS-006: the kind is read from any source vocabulary', () => {
|
|
expect(kindOfResult({ category: 'italian_restaurant' })).toBe('food')
|
|
expect(kindOfResult({ category: 'beach' })).toBe('beach')
|
|
expect(kindOfResult({ types: ['park'] })).toBe('nature')
|
|
expect(kindOfResult({ category: 'swimming_pool' })).toBe('activity')
|
|
})
|
|
})
|