From 7b3ab5eb6ba6b30f61fa3d9720d50f4654891084 Mon Sep 17 00:00:00 2001 From: SeanLeRoy Date: Thu, 14 Nov 2024 12:22:25 -0800 Subject: [PATCH] Ensure change data source is called --- .../services/DatabaseService/DatabaseServiceNoop.ts | 4 ++++ packages/core/state/selection/test/logics.test.ts | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/core/services/DatabaseService/DatabaseServiceNoop.ts b/packages/core/services/DatabaseService/DatabaseServiceNoop.ts index eb6045004..f4e24e5c9 100644 --- a/packages/core/services/DatabaseService/DatabaseServiceNoop.ts +++ b/packages/core/services/DatabaseService/DatabaseServiceNoop.ts @@ -1,6 +1,10 @@ import DatabaseService from "."; export default class DatabaseServiceNoop extends DatabaseService { + public deleteSourceMetadata(): Promise { + return Promise.reject("DatabaseServiceNoop:deleteSourceMetadata"); + } + public execute(): Promise { return Promise.reject("DatabaseServiceNoop:execute"); } diff --git a/packages/core/state/selection/test/logics.test.ts b/packages/core/state/selection/test/logics.test.ts index 662ff2b0d..edb8a9412 100644 --- a/packages/core/state/selection/test/logics.test.ts +++ b/packages/core/state/selection/test/logics.test.ts @@ -24,6 +24,7 @@ import { selectNearbyFile, SET_SORT_COLUMN, changeDataSources, + changeSourceMetadata, } from "../actions"; import { initialState, interaction } from "../../"; import Annotation from "../../../entity/Annotation"; @@ -40,6 +41,7 @@ import FileSort, { SortOrder } from "../../../entity/FileSort"; import { DatasetService } from "../../../services"; import { DataSource } from "../../../services/DataSourceService"; import HttpFileService from "../../../services/FileService/HttpFileService"; +import DatabaseServiceNoop from "../../../services/DatabaseService/DatabaseServiceNoop"; import FileDownloadServiceNoop from "../../../services/FileDownloadService/FileDownloadServiceNoop"; describe("Selection logics", () => { @@ -947,7 +949,17 @@ describe("Selection logics", () => { it("dispatches new hierarchy, filters, sort, source, & opened folders from given URL", async () => { // Arrange const annotations = annotationsJson.map((annotation) => new Annotation(annotation)); + class MockDatabaseService extends DatabaseServiceNoop { + public deleteSourceMetadata(): Promise { + return Promise.resolve(); + } + } const state = mergeState(initialState, { + interaction: { + platformDependentServices: { + databaseService: new MockDatabaseService(), + }, + }, metadata: { annotations, dataSources: mockDataSources, @@ -998,6 +1010,7 @@ describe("Selection logics", () => { payload: sortColumn, }) ).to.be.true; + expect(actions.includesMatch(changeSourceMetadata())).to.be.true; expect(actions.includesMatch(changeDataSources(mockDataSources))).to.be.true; }); });