import { screen, render, fireEvent, waitFor } from "@testing-library/react";
import { TimeStamp } from "..";
const date = new Date("2023-02-05T15:08:46.180456");
describe("TimeStamp component", () => {
test("Rendering Time Stamp", () => {
render()
})
test("Render PST timezone", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("02/05/2023 01:38:46");
})
test("Rendering Europe timezone", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("02/05/2023 10:38:46");
})
test("Rendering America/Toronto timezone", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("02/05/2023 04:38:46");
})
test("Rendering America/New_York timezone", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("02/05/2023 04:38:46");
})
test("Rendering Asia/Tokyo timezone", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("02/05/2023 18:38:46");
})
test("Rendering Asia/Kolkata timezone", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("02/05/2023 15:08:46");
})
test("Testing timeformat mm-dd-yyyy", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("38-Su-yyyy");
})
test("Testing Date only format", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("2023-02-05");
})
test("Testing Time only format", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("01:38:46");
})
test("Testing Date and time format", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("2023-02-05 01:38:46");
})
test("Testing Date and time with timezone format", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("2023-02-05 01:38:46 -08:00");
})
test("Testing Date and time with abbreviated timezone format", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("2023-02-05 01:38:46 AM z");
})
test("Empty field date", () => {
const wrapper = render()
const timestamp = wrapper.getByTestId("timestamp");
expect(timestamp.textContent).toBe("");
})
test("Input time is always should be in the UTC", () => {
const isoString = date.toISOString();
const isUtc = isoString.endsWith('Z');
expect(isUtc).toBe(true)
})
})