Skip to content

Commit

Permalink
Add missing tests for getTimeZoneByID and fromUnixTime with date
Browse files Browse the repository at this point in the history
  • Loading branch information
kewisch committed May 5, 2024
1 parent 1e504ba commit 67c138d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/component_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,4 +596,32 @@ suite('Component', function() {
assert.deepEqual(subject.jCal, fromICAL.jCal);
});

test('#getTimeZoneByID', async function() {
let icsData = await testSupport.loadSample('timezone_from_file.ics');
let vcalendar = new ICAL.Component(ICAL.parse(icsData));

let zone = vcalendar.getTimeZoneByID("Nowhere/Middle");
assert.equal(zone.tzid, "Nowhere/Middle");

// Zone remains in cache
vcalendar.removeSubcomponent("vtimezone");
zone = vcalendar.getTimeZoneByID("Nowhere/Middle");
assert.equal(zone.tzid, "Nowhere/Middle");

// Lookup from child component
zone = vcalendar.getFirstSubcomponent("vevent").getTimeZoneByID("Nowhere/Middle");
assert.equal(zone.tzid, "Nowhere/Middle");

// Non vcalendar root component
let vother = new ICAL.Component(["x-other", [], [["vtimezone", [], []]]]);
zone = vother.getFirstSubcomponent().getTimeZoneByID("Nowhere/Middle");
assert.isNull(zone);


// Missing timezone definition
vcalendar = new ICAL.Component(ICAL.parse(icsData));
vcalendar.removeSubcomponent("vtimezone");
zone = vcalendar.getTimeZoneByID("Nowhere/Middle");
assert.isNull(zone);
});
});
11 changes: 11 additions & 0 deletions test/time_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,17 @@ suite('icaltime', function() {
time.second,
otherTime.second
);

let date = new ICAL.Time({
year: 2012,
month: 1,
day: 5
});

date.fromUnixTime(date.toUnixTime());
assert.equal(date.hour, 0);
assert.equal(date.minute, 0);
assert.equal(date.second, 0);
});

suite('#adjust', function() {
Expand Down

0 comments on commit 67c138d

Please sign in to comment.