|
1 | 1 | import {describe, test, expect} from 'vitest'; |
2 | | -import {parseTribeEvents, type TribeEventsResponse} from '../enchantedparks.js'; |
| 2 | +import {parseTribeEvents, type TribeEventsResponse, EnchantedParks} from '../enchantedparks.js'; |
3 | 3 | import {parseICalFeed} from '../enchantedparks.js'; |
4 | 4 | import {parseAttractionsPage} from '../enchantedparks.js'; |
5 | 5 |
|
@@ -262,3 +262,55 @@ describe('parseAttractionsPage', () => { |
262 | 262 | expect(out).toEqual([{slug: 'renegade', name: 'Renegade'}]); |
263 | 263 | }); |
264 | 264 | }); |
| 265 | + |
| 266 | +describe('attraction location lookup', () => { |
| 267 | + // Expose protected `lookupAttractionLocation` for direct testing without |
| 268 | + // requiring a full destination lifecycle. |
| 269 | + class Probe extends EnchantedParks { |
| 270 | + public withLocations( |
| 271 | + m: Record<string, {latitude: number; longitude: number}>, |
| 272 | + ): this { |
| 273 | + this.attractionLocations = m; |
| 274 | + return this; |
| 275 | + } |
| 276 | + public lookup(name: string) { |
| 277 | + return this.lookupAttractionLocation(name); |
| 278 | + } |
| 279 | + } |
| 280 | + |
| 281 | + const sample = { |
| 282 | + "Snoopy's Junction": {latitude: 39.172367, longitude: -94.488782}, |
| 283 | + 'Timber Wolf': {latitude: 39.173334, longitude: -94.488856}, |
| 284 | + 'TIMBERTOWN RAILWAY': {latitude: 43.342000, longitude: -86.275000}, |
| 285 | + }; |
| 286 | + |
| 287 | + test('matches when WP source uses curly apostrophe and snapshot uses straight', () => { |
| 288 | + const p = new Probe({}).withLocations(sample); |
| 289 | + // Wiki snapshot has "Snoopy's Junction" (straight '). |
| 290 | + // WP source emits "Snoopy’s Junction" (curly ’). |
| 291 | + expect(p.lookup('Snoopy’s Junction')).toEqual({ |
| 292 | + latitude: 39.172367, longitude: -94.488782, |
| 293 | + }); |
| 294 | + }); |
| 295 | + |
| 296 | + test('matches case-insensitively', () => { |
| 297 | + const p = new Probe({}).withLocations(sample); |
| 298 | + expect(p.lookup('timber wolf')).toEqual({ |
| 299 | + latitude: 39.173334, longitude: -94.488856, |
| 300 | + }); |
| 301 | + // Lookup name uppercase, snapshot key uppercase — still matches. |
| 302 | + expect(p.lookup('Timbertown Railway')).toEqual({ |
| 303 | + latitude: 43.342000, longitude: -86.275000, |
| 304 | + }); |
| 305 | + }); |
| 306 | + |
| 307 | + test('returns undefined when the name is not in the snapshot', () => { |
| 308 | + const p = new Probe({}).withLocations(sample); |
| 309 | + expect(p.lookup('Definitely Not A Real Ride')).toBeUndefined(); |
| 310 | + }); |
| 311 | + |
| 312 | + test('returns undefined when no snapshot is configured', () => { |
| 313 | + const p = new Probe({}); |
| 314 | + expect(p.lookup('Timber Wolf')).toBeUndefined(); |
| 315 | + }); |
| 316 | +}); |
0 commit comments