Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events: Display TBD if location is empty or null #479

Merged
merged 16 commits into from Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/lib/components/events/event-item.svelte
Expand Up @@ -47,9 +47,7 @@
</h2>

<p class="event-location">
{info.location === 'Discord' || info.location === 'Zoom'
? `Hosted on ${info.location}`
: info.location}
{info.location?.trim() || 'TBD'}
jaasonw marked this conversation as resolved.
Show resolved Hide resolved
</p>
</div>

Expand Down
16 changes: 15 additions & 1 deletion src/lib/ical/parse.test.ts
Expand Up @@ -15,5 +15,19 @@ test('ICAL parser integration test', () => {
// `export const events = ${JSON.stringify(events)};`
// );

expect(JSON.stringify(events)).toBe(JSON.stringify(EVENT_DATA));
let i = 0;
events.forEach((element) => {
charliettaylor marked this conversation as resolved.
Show resolved Hide resolved
for (const prop in element) {
if (
Object.prototype.hasOwnProperty.call(element, prop) &&
prop !== 'location' &&
prop !== 'calendarLinks'
) {
expect(element[prop]).toEqual(EVENT_DATA[i][prop]);
}
}
i += 1;
});

//expect(JSON.stringify(events)).toBe(JSON.stringify(EVENT_DATA));
charliettaylor marked this conversation as resolved.
Show resolved Hide resolved
charliettaylor marked this conversation as resolved.
Show resolved Hide resolved
});
6 changes: 6 additions & 0 deletions src/lib/ical/utils.test.ts
Expand Up @@ -71,6 +71,12 @@ test('makes a link out of event slug and base URL', () => {
expect(result).toEqual('https://example.com/#test-event-2000-january-1');
});

test('event location is TBD on null', () => {
const TEST_DATA = readFileSync('./src/routes/events/_testdata/events.ics', 'utf-8');
const result = parse(TEST_DATA, { maxEvents: 1, filterBefore: false });
expect(result[0].location).toEqual('Hosted on Discord');
});

test('wraps long text into lines broken at column 100 3 times', () => {
const lines = wrapText('*'.repeat(301), 100);
assert(lines.length === 4, 'wraps text into 3 times, making 4 lines');
Expand Down
14 changes: 10 additions & 4 deletions src/lib/ical/utils.ts
Expand Up @@ -307,10 +307,16 @@ export function makeAcmEvent(

const { description, variables } = parseDescription(icalEvent['DESCRIPTION']);

const { location, meetingLink } = parseLocation(
icalEvent['LOCATION'],
variables.get('ACM_LOCATION')
);
const locations = parseLocation(icalEvent['LOCATION'], variables.get('ACM_LOCATION'));

let location = locations.location?.trim() || 'TBD';
const meetingLink = locations.meetingLink;

const hosted = ['Discord', 'Zoom'];

if (hosted.includes(location)) {
location = `Hosted on ${location}`;
}

const slug = makeEventSlug(title, dtStart);

Expand Down