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