Skip to content

Commit 2ae06a1

Browse files
cubehouseclaude
andcommitted
test(enchantedparks): cover attractionLocations name normalization
Added unit tests for the new lookup path that drives whether an emitted attraction retains its existing coordinates: - curly ’ (U+2019) vs straight ' apostrophe match - case-insensitive matching - missing-name returns undefined - no-snapshot returns undefined Full suite 1191/1191 pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 91f651b commit 2ae06a1

1 file changed

Lines changed: 53 additions & 1 deletion

File tree

src/parks/enchantedparks/__tests__/enchantedparks.test.ts

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {describe, test, expect} from 'vitest';
2-
import {parseTribeEvents, type TribeEventsResponse} from '../enchantedparks.js';
2+
import {parseTribeEvents, type TribeEventsResponse, EnchantedParks} from '../enchantedparks.js';
33
import {parseICalFeed} from '../enchantedparks.js';
44
import {parseAttractionsPage} from '../enchantedparks.js';
55

@@ -262,3 +262,55 @@ describe('parseAttractionsPage', () => {
262262
expect(out).toEqual([{slug: 'renegade', name: 'Renegade'}]);
263263
});
264264
});
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

Comments
 (0)