TimeZone.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. describe("errors", () => {
  2. test("called without new", () => {
  3. expect(() => {
  4. Temporal.TimeZone();
  5. }).toThrowWithMessage(TypeError, "Temporal.TimeZone constructor must be called with 'new'");
  6. });
  7. test("Invalid time zone name", () => {
  8. expect(() => {
  9. new Temporal.TimeZone("foo");
  10. }).toThrowWithMessage(RangeError, "Invalid time zone name");
  11. });
  12. });
  13. describe("normal behavior", () => {
  14. test("length is 1", () => {
  15. expect(Temporal.TimeZone).toHaveLength(1);
  16. });
  17. test("basic functionality", () => {
  18. const timeZone = new Temporal.TimeZone("UTC");
  19. expect(timeZone.id).toBe("UTC");
  20. expect(typeof timeZone).toBe("object");
  21. expect(timeZone).toBeInstanceOf(Temporal.TimeZone);
  22. expect(Object.getPrototypeOf(timeZone)).toBe(Temporal.TimeZone.prototype);
  23. });
  24. test("canonicalizes time zone name", () => {
  25. expect(new Temporal.TimeZone("Utc").id).toBe("UTC");
  26. expect(new Temporal.TimeZone("utc").id).toBe("UTC");
  27. expect(new Temporal.TimeZone("uTC").id).toBe("UTC");
  28. });
  29. // TODO: Add tests for time numeric zone offset once that's implemented
  30. });