Skip to content

Bugs with DateTime#toRelative padding #812

@arubacao

Description

@arubacao

Hi guys,

I've noticed an issue with toRelative with the padding option.
Before I try to explain anything, I simply added some tests to illustrate the issue best:

  // works as expected
  expect(base.plus({ minutes: 1, seconds: 30 }).toRelative({ base, padding: 30000 })).toBe(
    "in 2 minutes"
  );
 // doesn't work
  expect(base.plus({ seconds: 29 }).toRelative({ base, padding: 30000 })).toBe("in 29 seconds");

Test result:

  ● DateTime#toRelative allows padding

    expect(received).toBe(expected) // Object.is equality

    Expected: "in 29 seconds"
    Received: "in 59 seconds"

      39 |     "in 2 minutes"
      40 |   );
    > 41 |   expect(base.plus({ seconds: 29 }).toRelative({ base, padding: 30000 })).toBe("in 29 seconds");
         |                                                                           ^
      42 | });

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions