forked from cwlsn/ics-to-json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
icsToJson.test.js
59 lines (56 loc) · 1.5 KB
/
icsToJson.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import icsToJson from "./icsToJson";
const icsData = `BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
SUMMARY:Access-A-Ride Pickup
DTSTART;TZID=America/New_York:20130802T103400
DTEND;TZID=America/New_York:20130802T110400
LOCATION:1000 Broadway Ave.\, Brooklyn
DESCRIPTION: Access-A-Ride to 900 Jay St.\, Brooklyn
STATUS:CONFIRMED
SEQUENCE:3
BEGIN:VALARM
TRIGGER:-PT10M
DESCRIPTION:Pickup Reminder
ACTION:DISPLAY
END:VALARM
END:VEVENT
BEGIN:VEVENT
SUMMARY:Access-A-Ride Pickup
DTSTART;TZID=America/New_York:20130802T200000
DTEND;TZID=America/New_York:20130802T203000
LOCATION:900 Jay St.\, Brooklyn
DESCRIPTION: Access-A-Ride to 1000 Broadway Ave.\, Brooklyn
STATUS:CONFIRMED
SEQUENCE:3
BEGIN:VALARM
TRIGGER:-PT10M
DESCRIPTION:Pickup Reminder
ACTION:DISPLAY
END:VALARM
END:VEVENT
END:VCALENDAR`;
const sampleResult = [
{
startDate: "20130802T103400",
endDate: "20130802T110400",
description: "Access-A-Ride to 900 Jay St., Brooklyn",
location: "1000 Broadway Ave., Brooklyn",
summary: "Access-A-Ride Pickup"
},
{
startDate: "20130802T200000",
endDate: "20130802T203000",
description: "Access-A-Ride to 1000 Broadway Ave., Brooklyn",
location: "900 Jay St., Brooklyn",
summary: "Access-A-Ride Pickup"
}
];
test("sample file produces expected output", async () => {
let jsonData = icsToJson(icsData);
expect(jsonData).toEqual(sampleResult);
// run it again to make sure consecutive arrays work
jsonData = icsToJson(icsData);
expect(jsonData).toEqual(sampleResult);
});