-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Renames course-rooms pages folder * Adjusts AddContentModal tests to test for courses store usage * Fixes some smaller code smells --------- Co-authored-by: Odalys Adam <[email protected]> Co-authored-by: odalys-dataport <[email protected]>
- Loading branch information
1 parent
1ab3ec7
commit 9e18e0f
Showing
21 changed files
with
366 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// This test is necessary to ensure that the real Vuex course-store is functioning correctly. | ||
// The course-store is only invoked at this point, making it crucial to test it here. | ||
import AddContentModal from "./AddContentModal.vue"; | ||
|
||
import { | ||
createTestingVuetify, | ||
createTestingI18n, | ||
} from "@@/tests/test-utils/setup"; | ||
import { VSelect } from "vuetify/lib/components/index.mjs"; | ||
import courses from "@/store/courses"; | ||
import { createStore } from "vuex"; | ||
import ContentModule from "@/store/content"; | ||
import setupStores from "@@/tests/test-utils/setupStores"; | ||
import { nextTick } from "vue"; | ||
|
||
const testProps = { | ||
showCopyModal: true, | ||
resource: { | ||
title: "Test title", | ||
url: "test url", | ||
client: "test client", | ||
}, | ||
contentId: "Test content", | ||
items: [], | ||
}; | ||
|
||
const courseOptions = [ | ||
{ | ||
_id: "id1", | ||
name: "course1", | ||
isArchived: false, | ||
}, | ||
{ | ||
_id: "id2", | ||
name: "course2", | ||
isArchived: false, | ||
}, | ||
]; | ||
|
||
const createMockStore = () => { | ||
const mockStore = createStore({ | ||
modules: { | ||
courses, | ||
}, | ||
}); | ||
return { mockStore }; | ||
}; | ||
|
||
describe("AddContentModal with real Vuex courses-store", () => { | ||
const setup = (props: { | ||
showCopyModal: boolean; | ||
resource: { | ||
title: string; | ||
url: string; | ||
client: string; | ||
}; | ||
contentId: string; | ||
items?: Array<{ | ||
title: string; | ||
url: string; | ||
client: string; | ||
}>; | ||
}) => { | ||
setupStores({ | ||
contentModule: ContentModule, | ||
}); | ||
const { mockStore } = createMockStore(); | ||
|
||
const wrapper = mount(AddContentModal, { | ||
global: { | ||
plugins: [createTestingVuetify(), createTestingI18n()], | ||
mocks: { | ||
$store: mockStore, | ||
}, | ||
}, | ||
props, | ||
}); | ||
|
||
return { wrapper, mockStore }; | ||
}; | ||
|
||
it("should access the real courses store", async () => { | ||
const { wrapper, mockStore } = setup(testProps); | ||
|
||
mockStore.commit("courses/set", { items: courseOptions }); | ||
await nextTick(); | ||
|
||
const select = wrapper.findComponent(VSelect); | ||
const items = select.props("items"); | ||
expect(items).toHaveLength(2); | ||
}); | ||
}); |
Oops, something went wrong.