Update navigation tests

This commit is contained in:
Andrew Kingston 2024-04-10 16:06:37 +01:00
parent 380a0e7d30
commit b62c1e6fb3
1 changed files with 38 additions and 6 deletions

View File

@ -50,10 +50,18 @@ describe("Navigation store", () => {
{ {
url: "/home", url: "/home",
text: "Home", text: "Home",
type: "link",
}, },
{ {
url: "/test", url: "/test",
text: "Test", text: "Test",
type: "sublinks",
subLinks: [
{
text: "Foo",
url: "/bar",
},
],
}, },
] ]
@ -66,7 +74,7 @@ describe("Navigation store", () => {
.spyOn(ctx.test.navigationStore, "save") .spyOn(ctx.test.navigationStore, "save")
.mockImplementation(() => {}) .mockImplementation(() => {})
await ctx.test.navigationStore.saveLink("/test-url", "Testing") await ctx.test.navigationStore.saveLink("/test-url", "Testing", "BASIC")
expect(saveSpy).toBeCalledWith({ expect(saveSpy).toBeCalledWith({
...INITIAL_NAVIGATION_STATE, ...INITIAL_NAVIGATION_STATE,
@ -75,6 +83,8 @@ describe("Navigation store", () => {
{ {
url: "/test-url", url: "/test-url",
text: "Testing", text: "Testing",
type: "link",
roleId: "BASIC",
}, },
], ],
}) })
@ -87,6 +97,7 @@ describe("Navigation store", () => {
{ {
url: "/home", url: "/home",
text: "Home", text: "Home",
type: "link",
}, },
], ],
})) }))
@ -94,7 +105,7 @@ describe("Navigation store", () => {
.spyOn(ctx.test.navigationStore, "save") .spyOn(ctx.test.navigationStore, "save")
.mockImplementation(() => {}) .mockImplementation(() => {})
await ctx.test.navigationStore.saveLink("/home", "Home") await ctx.test.navigationStore.saveLink("/home", "Home", "BASIC")
expect(saveSpy).not.toHaveBeenCalled() expect(saveSpy).not.toHaveBeenCalled()
}) })
@ -106,14 +117,22 @@ describe("Navigation store", () => {
{ {
url: "/home", url: "/home",
text: "Home", text: "Home",
type: "link",
}, },
{ {
url: "/test", url: "/test",
text: "Test", text: "Test",
type: "link",
}, },
{ {
url: "/last", url: "/last",
text: "Last Link", text: "Last Link",
subLinks: [
{
text: "Foo",
url: "/home",
},
],
}, },
], ],
})) }))
@ -130,6 +149,8 @@ describe("Navigation store", () => {
{ {
text: "Last Link", text: "Last Link",
url: "/last", url: "/last",
type: "sublinks",
subLinks: [],
}, },
], ],
}) })
@ -140,14 +161,17 @@ describe("Navigation store", () => {
{ {
url: "/home", url: "/home",
text: "Home", text: "Home",
type: "link",
}, },
{ {
url: "/test", url: "/test",
text: "Test", text: "Test",
type: "link",
}, },
{ {
url: "/last", url: "/last",
text: "Last Link", text: "Last Link",
type: "link",
}, },
] ]
@ -168,10 +192,12 @@ describe("Navigation store", () => {
{ {
url: "/home", url: "/home",
text: "Home", text: "Home",
type: "link",
}, },
{ {
url: "/last", url: "/last",
text: "Last Link", text: "Last Link",
type: "link",
}, },
], ],
}) })
@ -180,10 +206,7 @@ describe("Navigation store", () => {
it("Should ignore a request to delete if there are no links", async ctx => { it("Should ignore a request to delete if there are no links", async ctx => {
const saveSpy = vi.spyOn(ctx.test.navigationStore, "save") const saveSpy = vi.spyOn(ctx.test.navigationStore, "save")
await ctx.test.navigationStore.deleteLink({ await ctx.test.navigationStore.deleteLink("/some-link")
url: "/some-link",
text: "Some Link",
})
expect(saveSpy).not.toBeCalled() expect(saveSpy).not.toBeCalled()
}) })
@ -201,10 +224,18 @@ describe("Navigation store", () => {
{ {
url: "/home", url: "/home",
text: "Home", text: "Home",
type: "link",
}, },
{ {
url: "/last", url: "/last",
text: "Last Link", text: "Last Link",
type: "sublinks",
subLinks: [
{
text: "Foo",
url: "/bar",
},
],
}, },
], ],
})) }))
@ -217,6 +248,7 @@ describe("Navigation store", () => {
{ {
url: "/new-link", url: "/new-link",
text: "New Link", text: "New Link",
type: "link",
}, },
], ],
} }