Skip to content

Commit f4d9d5a

Browse files
committed
fixing tests/unit/components/Records/Record/GeneralInfo/SavedSearches.spec.js
1 parent 1a3a59d commit f4d9d5a

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

src/components/Records/Record/GeneralInfo/SavedSearches.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ import { mapActions, mapGetters, mapState } from "vuex";
101101
102102
import RecordStatus from "@/components/Records/Shared/RecordStatus.vue";
103103
import RestClient from "@/lib/Client/RESTClient.js";
104-
// import saveSearch from "@/store";
105104
106105
const restClient = new RestClient();
107106
export default {

tests/unit/components/Records/Record/GeneralInfo/SavedSearches.spec.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as components from "vuetify/components";
66
import * as directives from "vuetify/directives";
77

88
import SavedSearches from "@/components/Records/Record/GeneralInfo/SavedSearches.vue";
9-
import saveSearchStore from "@/store";
109

1110
// Mock visualViewport because JSDOM doesn't implement it
1211
Object.defineProperty(window, "visualViewport", {
@@ -39,13 +38,6 @@ vi.mock("@/lib/Client/RESTClient.js", () => ({
3938
})),
4039
}));
4140

42-
// Mock the generic store import to intercept the commit
43-
vi.mock("@/store", () => ({
44-
default: {
45-
commit: vi.fn(),
46-
},
47-
}));
48-
4941
describe("SavedSearches.vue", () => {
5042
let wrapper;
5143
let store;
@@ -71,6 +63,12 @@ describe("SavedSearches.vue", () => {
7163
mockFetchRecord = vi.fn().mockResolvedValue();
7264
store = createStore({
7365
modules: {
66+
saveSearch: {
67+
namespaced: true,
68+
mutations: {
69+
setSaveSearchResult: vi.fn(),
70+
},
71+
},
7472
record: {
7573
namespaced: true,
7674
state: {
@@ -99,7 +97,7 @@ describe("SavedSearches.vue", () => {
9997
},
10098
},
10199
});
102-
100+
vi.spyOn(store, "commit");
103101
wrapper = mount(SavedSearches, {
104102
global: {
105103
plugins: [vuetify, store],
@@ -182,7 +180,7 @@ describe("SavedSearches.vue", () => {
182180
);
183181

184182
// 4. Verify the global store commit was fired
185-
expect(saveSearchStore.commit).toHaveBeenCalledWith(
183+
expect(store.commit).toHaveBeenCalledWith(
186184
"saveSearch/setSaveSearchResult",
187185
{ id: "updated_search_123" }, // Our mock return value
188186
);

0 commit comments

Comments
 (0)