Skip to content

Commit

Permalink
#927: Return null when calling intersection() on abutting Intervals (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
0x24a537r9 committed May 2, 2021
1 parent 91c5f87 commit c3be6a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/interval.js
Expand Up @@ -429,7 +429,7 @@ export default class Interval {
const s = this.s > other.s ? this.s : other.s,
e = this.e < other.e ? this.e : other.e;

if (s > e) {
if (s >= e) {
return null;
} else {
return Interval.fromDateTimes(s, e);
Expand Down
8 changes: 2 additions & 6 deletions test/interval/many.test.js
Expand Up @@ -111,12 +111,8 @@ test("Interval#intersection returns the intersection for overlapping intervals",
).toBeTruthy();
});

test("Interval#intersection returns empty for adjacent intervals", () => {
expect(
todayFrom(5, 8)
.intersection(todayFrom(8, 10))
.isEmpty()
).toBeTruthy();
test("Interval#intersection returns null for adjacent intervals", () => {
expect(todayFrom(5, 8).intersection(todayFrom(8, 10))).toBeNull();
});

test("Interval#intersection returns invalid for invalid intervals", () => {
Expand Down

0 comments on commit c3be6a4

Please sign in to comment.