Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions sources/ti.to/find-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function extractEventDetails(html, url) {
venueName: locationText,
venueAddress: locationText,
coordinates: null,
parsedDate: parseCalText(calText),
calText,
description,
};
}
Expand All @@ -176,20 +176,24 @@ function extractEventDetails(html, url) {
// First segment of venue address is the venue name
const venueName = venueAddress.split(",")[0].trim();

const parsedDate = parseCalText(calText);

return {
title,
venueName,
venueAddress,
coordinates,
parsedDate,
calText,
description,
};
}

function convertTitoEvent(url, eventDetails) {
const { title, parsedDate, description } = eventDetails;
const { title, calText, description } = eventDetails;
// Parsed only once the event is known to be at one of our venues. Tito
// lists every event an organiser runs, and one elsewhere in the country
// with a date and no time ("November 16th, 2026") has no performance to
// give - which should stop the run for a venue we carry, and not for one
// we don't.
const parsedDate = parseCalText(calText);
const eventPath = extractEventPath(url);
const duration = differenceInMinutes(
parsedDate.endDate,
Expand Down
55 changes: 55 additions & 0 deletions sources/ti.to/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,59 @@ describe(`${attributes.name}`, () => {
expect(output).toHaveLength(0);
});
});

// Markup from https://ti.to/queereast/girlfriends_uok_2026, which gives a
// date and no time
describe("an event with a date and no time", () => {
const html = `
<h1 class="event-title">Girlfriends (University of Kent)</h1>
<div class="tito-event-homepage--basic-info tito-event-homepage--basic-info-cal">
<a href="https://checkout.tito.io/queereast/girlfriends_uok_2026?format=ics">
November 16th, 2026
</a>
</div>
<div class="tito-event-homepage--basic-info tito-event-homepage--basic-info-location">
<a href="https://maps.google.com/maps?q=51.2967395%2C1.0630042+%28Lupino+Cinema+at+the+University+of+Kent%2C+Grimond+Building%2C+University+of+Kent%2C+Canterbury%2C+CT2+7NG%29">
Lupino Cinema at the University of Kent
</a>
</div>
<ul class="tito-venues"><li><a href="#"><span>
Lupino Cinema at the University of Kent, Grimond Building, University of Kent, Canterbury, CT2 7NG
</span></a></li></ul>`;
const venues = {
queereast: {
moviePages: {
"https://ti.to/queereast/girlfriends_uok_2026": html,
},
},
};

it("is passed over for a cinema it isn't at", async () => {
readJSON.mockImplementation(() => venues);

const output = await findEvents({
name: "The Garden Cinema",
alternativeNames: [],
address: "39-41 Parker St, London WC2B 5PQ, UK",
geo: { lat: 51.5162287, lon: -0.1213371 },
});

expect(output).toHaveLength(0);
});

it("throws for the cinema it is at", async () => {
readJSON.mockImplementation(() => venues);

await expect(
findEvents({
name: "Lupino Cinema at the University of Kent",
alternativeNames: [],
address: "Grimond Building, University of Kent, Canterbury, CT2 7NG",
geo: { lat: 51.2967395, lon: 1.0630042 },
}),
).rejects.toThrow(
'Expected en-dash in calendar text: "November 16th, 2026"',
);
});
});
});
Loading