Skip to content

Commit ffd2936

Browse files
committed
feat: add tests for event end dates and create test data for Cookie Cutter and Typewind events
1 parent 3bc26dc commit ffd2936

File tree

3 files changed

+101
-1
lines changed

3 files changed

+101
-1
lines changed

tests/events.test.js

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import fs from 'fs'
22

33
import { getEventBySlug, parseEvent } from '../api/events'
4+
import testTypewindEvent from './testData/2025-05-02-typewind'
5+
import testCookieCutterEvent from './testData/2025-05-02-Cookie-Cutter'
46

57
describe('Event files', () => {
68
test('All event files have ".md" extension', () => {
@@ -24,4 +26,53 @@ describe('Event files', () => {
2426
expect(() => parseEvent(event)).not.toThrowError()
2527
})
2628
})
27-
})
29+
30+
test('An event has an end date and does not throw an error', () => {
31+
const eventFiles = fs.readdirSync('content/events')
32+
33+
const events = eventFiles.map((fileName) => {
34+
const slug = fileName.replace('.md', '')
35+
const event = getEventBySlug(slug)
36+
return event
37+
})
38+
39+
events.forEach((event) => {
40+
expect(() => parseEvent(event)).not.toThrowError()
41+
})
42+
})
43+
44+
test('An event returns an endDate', () => {
45+
const event = testCookieCutterEvent
46+
const parsedEvent = parseEvent(event)
47+
expect(parsedEvent).toEqual(expect.objectContaining({ endDate: '07/02' }))
48+
})
49+
50+
test('An event has an invalid start time and does not throw an error', () => {
51+
const eventFiles = fs.readdirSync('content/events')
52+
53+
const events = eventFiles.map((fileName) => {
54+
const slug = fileName.replace('.md', '')
55+
const event = getEventBySlug(slug)
56+
return event
57+
})
58+
59+
events.forEach((event) => {
60+
expect(() => parseEvent(event)).not.toThrowError()
61+
})
62+
})
63+
64+
test('An event with an invalid start time retunrs TBD', () => {
65+
const event = testTypewindEvent
66+
const parsedEvent = parseEvent(event)
67+
expect(parsedEvent).toEqual(
68+
expect.objectContaining({
69+
formattedDate: expect.objectContaining({
70+
startTime: {
71+
pt: 'TBD',
72+
utc: 'TBD',
73+
},
74+
}),
75+
}),
76+
)
77+
})
78+
})
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const cookieCutterEvent = {
2+
slug: '2025-05-02-Cookie-Cutter',
3+
title: 'Open Source Friday Brasil: Cookie Cutter and FastAPI',
4+
metaTitle: 'Open Source Friday Brasil: Cookie Cutter and FastAPI',
5+
metaDesc:
6+
'Join Arthur Henrique to discuss Cookiecutter template for FastAPI projects using Machine Learning, uv, GitHub Actions, and Pytests.',
7+
date: '05/02',
8+
endDate: '07/02',
9+
UTCStartTime: '16:00',
10+
UTCEndTime: '17:00',
11+
type: 'stream',
12+
location: 'Virtual',
13+
language: 'Portuguese',
14+
userName: 'GitHub',
15+
userLink: 'https://www.youtube.com/github',
16+
linkUrl: 'https://www.youtube.com/github',
17+
content:
18+
'\n' +
19+
'Join [Arthur Henrique](https://github.com/arthurhenrique) to discuss Cookiecutter template for FastAPI projects using Machine Learning, uv, GitHub Actions, and Pytests.\n' +
20+
'\n' +
21+
"Open Source Fridays Brasil stream weekly on GitHub's [Twitch](https://www.twitch.tv/githubbrasil), [YouTube](https://github.com/youtube), and [LinkedIn](https://www.linkedin.com/company/githubbrasil).\n",
22+
link: '/schedule/2025-05-02-Cookie-Cutter',
23+
}
24+
25+
export default cookieCutterEvent
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const typewindEvent = {
2+
slug: '2025-05-02-typewind',
3+
title: 'Open Source Friday: Typewind',
4+
metaTitle: 'Open Source Friday: Typewind',
5+
metaDesc:
6+
'Chat with Mokshit Jain about Typewind, a build tool focused on improving web performance.',
7+
date: '05/02',
8+
UTCStartTime: 'G:00',
9+
UTCEndTime: '7:00',
10+
type: 'stream',
11+
location: 'Virtual',
12+
language: 'English',
13+
userName: 'GitHub',
14+
userLink: 'https://www.twitch.tv/github/schedule',
15+
linkUrl: 'https://www.twitch.tv/github/schedule',
16+
content:
17+
'\n' +
18+
'Chat with [Mokshit Jain](https://github.com/Mokshit06) about [Typewind](https://github.com/Mokshit06/typewind), a build tool focused on improving web performance. Explore the journey of creating Typewind and contributions to the open-source build-tools space.\n' +
19+
'\n' +
20+
"[Open Source Fridays](https://www.youtube.com/playlist?list=PL0lo9MOBetEFmtstItnKlhJJVmMghxc0P) stream weekly on GitHub's [Twitch](https://www.twitch.tv/github), [YouTube](https://www.youtube.com/github), and [LinkedIn](https://www.linkedin.com/company/github).\n",
21+
link: '/schedule/2025-05-02-typewind',
22+
}
23+
24+
export default typewindEvent

0 commit comments

Comments
 (0)