Skip to content

Commit

Permalink
Upgraded dependencies
Browse files Browse the repository at this point in the history
Fixes: #2077
  • Loading branch information
hudson-newey committed Oct 17, 2023
1 parent ee13ed3 commit 37d89f9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/app/components/regions/pages/new/new.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe("routing and resolvers", () => {

function setup(path) {
// boiler plate adapted from https://ng-mocks.sudo.eu/guides/route
const fixture = MockRender(RouterOutlet);
const fixture = MockRender(RouterOutlet, {});
const router = fixture.point.injector.get(Router);
const location = fixture.point.injector.get(Location);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ describe("AudioRecordingsFilter", () => {
const getDateToggleInput = () =>
spectator.query<HTMLInputElement>("#date-filtering");
const getDateInputWrapper = () =>
spectator.query("#date-filters-wrapper", { read: NgbCollapse });
spectator.query<HTMLDivElement>("#date-filters-wrapper");
const getDateStartedAfterInput = () =>
spectator.query<HTMLInputElement>("#date-started-after");
const getDateFinishedBeforeInput = () =>
spectator.query<HTMLInputElement>("#date-finished-before");
const getTimeOfDayInputWrapper = () =>
spectator.query("#time-filters-wrapper", { read: NgbCollapse });
spectator.query<HTMLDivElement>("#time-filters-wrapper");
const getTimeOfDayToggleInput = () =>
spectator.query<HTMLInputElement>("#time-filtering");
const getIgnoreDaylightSavingsInput = () =>
Expand All @@ -96,30 +96,38 @@ describe("AudioRecordingsFilter", () => {
updateForm();
}

function toggleTimeOfDayFilters() {
function toggleTimeOfDayFilters(): void {
const input = getTimeOfDayToggleInput();
input.click();
input.dispatchEvent(new Event("input"));

updateForm();
}

function toggleDateFilters() {
function toggleDateFilters(): void {
const input = getDateToggleInput();
input.click();
input.dispatchEvent(new Event("input"));

updateForm();
}

function toggleIgnoreDaylightSavings() {
function toggleIgnoreDaylightSavings(): void {
const input = getIgnoreDaylightSavingsInput();
input.click();
input.dispatchEvent(new Event("input"));

updateForm();
}

/** predicates if the element is both collapsable and collapsed */
function isDivCollapsed(element: HTMLDivElement): boolean {
const isCollapsable: boolean = element.classList.contains("collapse");
const isCollapsed: boolean = !element.classList.contains("show");

return isCollapsable && isCollapsed;
}

// start of assertion
it("should create", () => {
expect(spectator.component).toBeInstanceOf(DateTimeFilterComponent);
Expand All @@ -128,40 +136,40 @@ describe("AudioRecordingsFilter", () => {
describe("date filter input", () => {
it("should initially hide date filter input", fakeAsync(() => {
expect(getDateToggleInput()).toExist();
expect(getDateInputWrapper().collapsed).toBeTrue();
expect(isDivCollapsed(getDateInputWrapper())).toBeTrue();
}));

it("should show date filter input when the date filter checkbox is set", fakeAsync(() => {
toggleDateFilters();
expect(getDateToggleInput()).toBeTruthy();
expect(getDateInputWrapper().collapsed).toBeFalse();
expect(isDivCollapsed(getDateInputWrapper())).toBeFalse();
}));

it("should hide date filter input when the date filter checkbox is clicked twice", fakeAsync(() => {
toggleDateFilters();
toggleDateFilters();
expect(getDateToggleInput()).toExist();
expect(getDateInputWrapper().collapsed).toBeTrue();
expect(isDivCollapsed(getDateInputWrapper())).toBeTrue();
}));
});

describe("time filter input", () => {
it("should initially hide time of day filters", fakeAsync(() => {
expect(getTimeOfDayToggleInput()).toExist();
expect(getTimeOfDayInputWrapper().collapsed).toBeTrue();
expect(isDivCollapsed(getTimeOfDayInputWrapper())).toBeTrue();
}));

it("should show time of day filter input when the time of day filter checkbox is set", fakeAsync(() => {
toggleTimeOfDayFilters();
expect(getTimeOfDayToggleInput()).toExist();
expect(getTimeOfDayInputWrapper().collapsed).toBeFalse();
expect(isDivCollapsed(getTimeOfDayInputWrapper())).toBeFalse();
}));

it("should hide timeOfDay filter input when the time of day filter checkbox is clicked twice", fakeAsync(() => {
toggleTimeOfDayFilters();
toggleTimeOfDayFilters();
expect(getTimeOfDayToggleInput()).toExist();
expect(getTimeOfDayInputWrapper().collapsed).toBeTrue();
expect(isDivCollapsed(getTimeOfDayInputWrapper())).toBeTrue();
}));

it("should initially have day light savings time enabled", fakeAsync(() => {
Expand Down Expand Up @@ -297,13 +305,19 @@ describe("AudioRecordingsFilter", () => {
});

describe("filters events", () => {
function assertLastFilterUpdate(expectedFilter: Filters<AudioRecording>): void {
function assertLastFilterUpdate(
expectedFilter: Filters<AudioRecording>
): void {
const mostRecentFilterUpdate = filterChangeSpy.calls.mostRecent().args[0];

const expectedFilterSerialized = JSON.stringify(expectedFilter);
const mostRecentFilterUpdateSerialized = JSON.stringify(mostRecentFilterUpdate);
const mostRecentFilterUpdateSerialized = JSON.stringify(
mostRecentFilterUpdate
);

expect(mostRecentFilterUpdateSerialized).toEqual(expectedFilterSerialized);
expect(mostRecentFilterUpdateSerialized).toEqual(
expectedFilterSerialized
);
}

// date events where a filter update should not be emitted
Expand Down Expand Up @@ -417,7 +431,7 @@ describe("AudioRecordingsFilter", () => {

toggleDateFilters();

assertLastFilterUpdate({ });
assertLastFilterUpdate({});
}));

// time events where a filter update should not be emitted
Expand Down Expand Up @@ -452,7 +466,7 @@ describe("AudioRecordingsFilter", () => {

toggleTimeOfDayFilters();

assertLastFilterUpdate({ });
assertLastFilterUpdate({});
}));

it("should not emit time filters if the time bounds are set, but the 'Filter by time of day' checkbox is not checked", fakeAsync(() => {
Expand Down
13 changes: 7 additions & 6 deletions src/app/services/baw-api/resolver-common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { MockModel } from "./mock/baseApiMock.service";
import { hasResolvedSuccessfully, retrieveResolvers } from "./resolver-common";

// TODO Write unit tests
xdescribe("API Resolvers", () => {
xdescribe("BawResolvers", () => {});
xdescribe("Resolvers", () => {});
xdescribe("ListResolver", () => {});
xdescribe("ShowResolver", () => {});
});
//! I've commented these tests out because for some unknown reason, it breaks CI
// xdescribe("API Resolvers", () => {
// xdescribe("BawResolvers", () => {});
// xdescribe("Resolvers", () => {});
// xdescribe("ListResolver", () => {});
// xdescribe("ShowResolver", () => {});
// });

describe("hasResolvedSuccessfully", () => {
it("should return true if empty object", () => {
Expand Down

0 comments on commit 37d89f9

Please sign in to comment.