Skip to content

Commit

Permalink
revisit unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sixlighthouses committed Aug 10, 2023
1 parent b958d0b commit b444618
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/ReactViews/Workbench/Controls/DateTimeSelectorSectionSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import WebMapServiceCatalogItem from "../../../../lib/Models/Catalog/Ows/WebMapS
import Terria from "../../../../lib/Models/Terria";
import { formatDateTime } from "../../../../lib/ReactViews/BottomDock/Timeline/DateFormats";
import DateTimeSelectorSection from "../../../../lib/ReactViews/Workbench/Controls/DateTimeSelectorSection";
import { getAdjustedTime } from "../../../../lib/Core/DateUtils";

describe("DateTimeSelectorSection", function () {
let terria: Terria;
Expand Down Expand Up @@ -75,16 +76,20 @@ describe("DateTimeSelectorSection", function () {
});

it("A datetime selector can be formatted with a named option", async function () {
wmsItem.setTrait("definition", "dateFormat", "isoDateTime");
wmsItem.setTrait("definition", "dateFormat", "fullDate");
wmsItem.setTrait("definition", "isStaticDate", true);
const expectedDateStr = getAdjustedTime(wmsItem);
expect(buttons).toBeDefined();
expect(buttons.length).toEqual(5);
expect(currentDateBtn.children[0].children[0].children[0]).toEqual(
"2014-01-01T00:00:00+0000"
expectedDateStr
);
});

it("A datetime selector can be formatted with a timeZone -03:00", async function () {
wmsItem.setTrait("definition", "timeZone", "-03:00");
wmsItem.setTrait("definition", "isStaticDate", true);
const expectedDateStr = getAdjustedTime(wmsItem);
expect(buttons).toBeDefined();
expect(buttons.length).toEqual(5);
expect(currentDateBtn.children[0].children[0].children[0]).toEqual(
Expand All @@ -94,11 +99,17 @@ describe("DateTimeSelectorSection", function () {

it("A datetime selector can be formatted with a timeZone +11", async function () {
wmsItem.setTrait("definition", "timeZone", "+11");
wmsItem.setTrait("definition", "dateFormat", "isoDateTime");
wmsItem.setTrait(
"definition",
"dateFormat",
"dddd, mmmm dS, yyyy, h:MM:ss TT"
);
wmsItem.setTrait("definition", "isStaticDate", true);
const expectedDateStr = getAdjustedTime(wmsItem);
expect(buttons).toBeDefined();
expect(buttons.length).toEqual(5);
expect(currentDateBtn.children[0].children[0].children[0]).toEqual(
"2014-01-01T11:00:00+0000"
expectedDateStr
);
});

Expand Down

0 comments on commit b444618

Please sign in to comment.