Skip to content

Commit

Permalink
Merge pull request #13 from rufo123/code
Browse files Browse the repository at this point in the history
Adjusted unstable unit Tests
  • Loading branch information
rufo123 authored Aug 11, 2023
2 parents 38f26c6 + d05ff2f commit d1c947c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ describe("FetchDataComponent", () => {
component.sortData(SortTime.AllTime);
const date = new Date();
date.setFullYear(1);
date.setMilliseconds(0);
component.dateToCountHoursFrom.setMilliseconds(0);
expect(component.dateToCountHoursFrom).toEqual(date);
});

Expand Down Expand Up @@ -429,6 +431,14 @@ describe("FetchDataComponent", () => {
expect(component.sortDirection).toBe(1);
});

function removeMsFromISOString(ISOstring: string): string {
const indexOfDot = ISOstring.indexOf(".");
if (indexOfDot !== -1) {
return ISOstring.substring(0, indexOfDot) + "Z";
}
return ISOstring;
}

interface Stats {
id: number;
latestName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ describe("VymazatComponent", () => {

it("should get current time as ISO string", () => {
const currentDate: Date = new Date();
const currentDateISO = currentDate.toISOString();
expect(component.getCurrentTimeAsIsoString()).toBe(currentDateISO);
const currentDateISO = removeMsFromISOString(currentDate.toISOString());
const returnedISOString = removeMsFromISOString(
component.getCurrentTimeAsIsoString()
);

expect(returnedISOString).toBe(currentDateISO);
});

it("should get graph data latest sorted by month", () => {
Expand Down Expand Up @@ -177,6 +181,14 @@ describe("VymazatComponent", () => {
expect(localStorageMock["stats-etag"]).toBe("new-etag");
});

function removeMsFromISOString(ISOstring: string): string {
const indexOfDot = ISOstring.indexOf(".");
if (indexOfDot !== -1) {
return ISOstring.substring(0, indexOfDot) + "Z";
}
return ISOstring;
}

enum SortTime {
Year = "year",
Month = "month",
Expand Down

0 comments on commit d1c947c

Please sign in to comment.