chore: add test case to user searcher to register with spotlight on init

This commit is contained in:
Andrew Bastin
2023-07-04 15:03:50 +05:30
parent 14202a3eed
commit 6b38363fab

View File

@@ -2,6 +2,7 @@ import { beforeEach, describe, it, expect, vi } from "vitest"
import { TestContainer } from "dioc/testing"
import { UserSpotlightSearcherService } from "../user.searcher"
import { nextTick, ref } from "vue"
import { SpotlightService } from "../.."
async function flushPromises() {
return await new Promise((r) => setTimeout(r))
@@ -37,6 +38,22 @@ describe("UserSearcher", () => {
actionsMock.invokeAction.mockReset()
})
it("registers with the spotlight service upon initialization", async () => {
const container = new TestContainer()
const registerSearcherFn = vi.fn()
container.bindMock(SpotlightService, {
registerSearcher: registerSearcherFn,
})
const user = container.bind(UserSpotlightSearcherService)
await flushPromises()
expect(registerSearcherFn).toHaveBeenCalledOnce()
expect(registerSearcherFn).toHaveBeenCalledWith(user)
})
it("if login action is available, the search result should have the login result", async () => {
const container = new TestContainer()