mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibJS/Tests: Add tests for Temporal.Instant() constructor
This commit is contained in:
parent
117323f2d9
commit
6531485251
Notes:
sideshowbarker
2024-07-18 10:02:28 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/65314852513 Pull-request: https://github.com/SerenityOS/serenity/pull/8568 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/bgianfo ✅
1 changed files with 30 additions and 0 deletions
|
@ -0,0 +1,30 @@
|
|||
describe("errors", () => {
|
||||
test("called without new", () => {
|
||||
expect(() => {
|
||||
Temporal.Instant();
|
||||
}).toThrowWithMessage(TypeError, "Temporal.Instant constructor must be called with 'new'");
|
||||
});
|
||||
|
||||
test("argument must be coercible to bigint", () => {
|
||||
expect(() => {
|
||||
new Temporal.Instant(123);
|
||||
}).toThrowWithMessage(TypeError, "Cannot convert number to BigInt");
|
||||
expect(() => {
|
||||
new Temporal.Instant("foo");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid value for BigInt: foo");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("length is 1", () => {
|
||||
expect(Temporal.Instant).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
const instant = new Temporal.Instant(123n);
|
||||
expect(instant.epochNanoseconds).toBe(123n);
|
||||
expect(typeof instant).toBe("object");
|
||||
expect(instant).toBeInstanceOf(Temporal.Instant);
|
||||
expect(Object.getPrototypeOf(instant)).toBe(Temporal.Instant.prototype);
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue