mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
LibJS: Implement Temporal.PlainTime.prototype.add()
This commit is contained in:
parent
97f6c6029f
commit
4bf391ff4b
3 changed files with 52 additions and 0 deletions
|
@ -0,0 +1,27 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.PlainTime.prototype.add).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const plainTime = new Temporal.PlainTime(1, 1, 1, 1, 1, 1);
|
||||
const duration = new Temporal.Duration(2021, 10, 1, 1, 0, 1, 2, 3, 4, 5);
|
||||
const result = plainTime.add(duration);
|
||||
expect(result.hour).toBe(1);
|
||||
expect(result.minute).toBe(2);
|
||||
expect(result.second).toBe(3);
|
||||
expect(result.millisecond).toBe(4);
|
||||
expect(result.microsecond).toBe(5);
|
||||
expect(result.nanosecond).toBe(6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("invalid duration-like", () => {
|
||||
const plainTime = new Temporal.PlainTime(1, 1, 1, 1, 1, 1);
|
||||
const invalidDuration = { foo: 1, bar: 2 };
|
||||
expect(() => {
|
||||
plainTime.add(invalidDuration);
|
||||
}).toThrowWithMessage(TypeError, "Invalid duration-like object");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue