-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NotificationsManagement component tests
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
client/src/components/admin/Notifications/NotificationsManagement.test.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,55 @@ | ||
import { createTestingPinia } from "@pinia/testing"; | ||
import { getLocalVue } from "@tests/jest/helpers"; | ||
import { shallowMount } from "@vue/test-utils"; | ||
import flushPromises from "flush-promises"; | ||
import { setActivePinia } from "pinia"; | ||
|
||
import { mockFetcher } from "@/api/schema/__mocks__"; | ||
|
||
import NotificationsManagement from "./NotificationsManagement.vue"; | ||
|
||
jest.mock("@/api/schema"); | ||
|
||
const localVue = getLocalVue(true); | ||
|
||
const selectors = { | ||
sendNotificationButton: "#send-notification-button", | ||
createBroadcastButton: "#create-broadcast-button", | ||
} as const; | ||
|
||
async function mountNotificationsManagement(config: any = {}) { | ||
const pinia = createTestingPinia(); | ||
setActivePinia(pinia); | ||
|
||
mockFetcher.path("/api/configuration").method("get").mock({ data: config }); | ||
|
||
const wrapper = shallowMount(NotificationsManagement as object, { | ||
localVue, | ||
pinia, | ||
stubs: { | ||
FontAwesomeIcon: true, | ||
}, | ||
}); | ||
|
||
await flushPromises(); | ||
|
||
return wrapper; | ||
} | ||
|
||
describe("NotificationsManagement.vue", () => { | ||
it("should render the create notification buttons if the notification system is enabled", async () => { | ||
const config = { enable_notification_system: true }; | ||
const wrapper = await mountNotificationsManagement(config); | ||
|
||
expect(wrapper.find(selectors.sendNotificationButton).exists()).toBe(true); | ||
expect(wrapper.find(selectors.createBroadcastButton).exists()).toBe(true); | ||
}); | ||
|
||
it("should not render the create notification buttons if the notification system is disabled", async () => { | ||
const config = { enable_notification_system: false }; | ||
const wrapper = await mountNotificationsManagement(config); | ||
|
||
expect(wrapper.find(selectors.sendNotificationButton).exists()).toBe(false); | ||
expect(wrapper.find(selectors.createBroadcastButton).exists()).toBe(false); | ||
}); | ||
}); |