diff --git a/src/app/components/regions/pages/new/new.component.spec.ts b/src/app/components/regions/pages/new/new.component.spec.ts index 96afc5cd9..8b1a035c8 100644 --- a/src/app/components/regions/pages/new/new.component.spec.ts +++ b/src/app/components/regions/pages/new/new.component.spec.ts @@ -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); diff --git a/src/app/components/shared/date-time-filter/date-time-filter.component.spec.ts b/src/app/components/shared/date-time-filter/date-time-filter.component.spec.ts index 12c4e2d81..7892a2ea7 100644 --- a/src/app/components/shared/date-time-filter/date-time-filter.component.spec.ts +++ b/src/app/components/shared/date-time-filter/date-time-filter.component.spec.ts @@ -74,13 +74,13 @@ describe("AudioRecordingsFilter", () => { const getDateToggleInput = () => spectator.query("#date-filtering"); const getDateInputWrapper = () => - spectator.query("#date-filters-wrapper", { read: NgbCollapse }); + spectator.query("#date-filters-wrapper"); const getDateStartedAfterInput = () => spectator.query("#date-started-after"); const getDateFinishedBeforeInput = () => spectator.query("#date-finished-before"); const getTimeOfDayInputWrapper = () => - spectator.query("#time-filters-wrapper", { read: NgbCollapse }); + spectator.query("#time-filters-wrapper"); const getTimeOfDayToggleInput = () => spectator.query("#time-filtering"); const getIgnoreDaylightSavingsInput = () => @@ -96,7 +96,7 @@ describe("AudioRecordingsFilter", () => { updateForm(); } - function toggleTimeOfDayFilters() { + function toggleTimeOfDayFilters(): void { const input = getTimeOfDayToggleInput(); input.click(); input.dispatchEvent(new Event("input")); @@ -104,7 +104,7 @@ describe("AudioRecordingsFilter", () => { updateForm(); } - function toggleDateFilters() { + function toggleDateFilters(): void { const input = getDateToggleInput(); input.click(); input.dispatchEvent(new Event("input")); @@ -112,7 +112,7 @@ describe("AudioRecordingsFilter", () => { updateForm(); } - function toggleIgnoreDaylightSavings() { + function toggleIgnoreDaylightSavings(): void { const input = getIgnoreDaylightSavingsInput(); input.click(); input.dispatchEvent(new Event("input")); @@ -120,6 +120,14 @@ describe("AudioRecordingsFilter", () => { 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); @@ -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(() => { @@ -297,13 +305,19 @@ describe("AudioRecordingsFilter", () => { }); describe("filters events", () => { - function assertLastFilterUpdate(expectedFilter: Filters): void { + function assertLastFilterUpdate( + expectedFilter: Filters + ): 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 @@ -417,7 +431,7 @@ describe("AudioRecordingsFilter", () => { toggleDateFilters(); - assertLastFilterUpdate({ }); + assertLastFilterUpdate({}); })); // time events where a filter update should not be emitted @@ -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(() => { diff --git a/src/app/services/baw-api/resolver-common.spec.ts b/src/app/services/baw-api/resolver-common.spec.ts index 445c1b376..cd3ca8c61 100644 --- a/src/app/services/baw-api/resolver-common.spec.ts +++ b/src/app/services/baw-api/resolver-common.spec.ts @@ -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", () => {