-
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.
Merge branch 'main' of github.com:hpi-schul-cloud/nuxt-client into BC…
…-7985-sidebar-selection
- Loading branch information
Showing
19 changed files
with
648 additions
and
445 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
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
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
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
104 changes: 104 additions & 0 deletions
104
src/modules/feature/media-shelf/MediaBoardExternalToolDeletedElement.unit.ts
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,104 @@ | ||
import { | ||
createTestingI18n, | ||
createTestingVuetify, | ||
} from "@@/tests/test-utils/setup"; | ||
import { deletedElementResponseFactory } from "@@/tests/test-utils"; | ||
import { mount } from "@vue/test-utils"; | ||
import { BoardMenuActionDelete } from "@ui-board"; | ||
import { nextTick } from "vue"; | ||
import { ComponentProps } from "vue-component-type-helpers"; | ||
import { VBtn } from "vuetify/lib/components/index.mjs"; | ||
import MediaBoardExternalToolElementMenu from "./MediaBoardExternalToolElementMenu.vue"; | ||
import MediaBoardDeletedElement from "./MediaBoardExternalToolDeletedElement.vue"; | ||
|
||
describe("MediaBoardDeletedElement", () => { | ||
const getWrapper = ( | ||
props: ComponentProps<typeof MediaBoardDeletedElement>, | ||
stubThreeDotMenu = true | ||
) => { | ||
const wrapper = mount(MediaBoardDeletedElement, { | ||
global: { | ||
plugins: [createTestingVuetify(), createTestingI18n()], | ||
}, | ||
props, | ||
stubs: { | ||
MediaBoardExternalToolElementMenu: stubThreeDotMenu, | ||
}, | ||
}); | ||
|
||
return { | ||
wrapper, | ||
}; | ||
}; | ||
|
||
describe("three dot menu", () => { | ||
describe("when clicking on the the three dot menu", () => { | ||
const setupOverlayDiv = () => { | ||
const overlayDiv = document.createElement("div"); | ||
overlayDiv.className = "v-overlay-container"; | ||
document.body.append(); | ||
}; | ||
|
||
const setup = () => { | ||
const deletedElement = deletedElementResponseFactory.build(); | ||
|
||
const { wrapper } = getWrapper( | ||
{ | ||
element: deletedElement, | ||
}, | ||
false | ||
); | ||
|
||
setupOverlayDiv(); | ||
|
||
return { | ||
wrapper, | ||
}; | ||
}; | ||
|
||
afterEach(() => { | ||
document.body.innerHTML = ""; | ||
}); | ||
|
||
it("should show the delete action", async () => { | ||
const { wrapper } = setup(); | ||
|
||
const menuBtn = wrapper | ||
.getComponent(MediaBoardExternalToolElementMenu) | ||
.getComponent(VBtn); | ||
await menuBtn.trigger("click"); | ||
|
||
const deleteAction = wrapper.findComponent(BoardMenuActionDelete); | ||
|
||
expect(deleteAction.exists()).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe("when deleting the element from the menu", () => { | ||
const setup = () => { | ||
const deletedElement = deletedElementResponseFactory.build(); | ||
|
||
const { wrapper } = getWrapper({ | ||
element: deletedElement, | ||
}); | ||
|
||
return { | ||
wrapper, | ||
deletedElement, | ||
}; | ||
}; | ||
|
||
it("should emit a delete event", async () => { | ||
const { wrapper, deletedElement } = setup(); | ||
|
||
const menu = wrapper.getComponent(MediaBoardExternalToolElementMenu); | ||
menu.vm.$emit("delete:element"); | ||
await nextTick(); | ||
|
||
expect(wrapper.emitted("delete:element")).toEqual([ | ||
[deletedElement.id], | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.