1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-23 15:24:21 +00:00
sophon/frontend/src/utils/ParsePath.test.js

79 lines
1.7 KiB
JavaScript
Raw Normal View History

import { parsePath } from "./ParsePath"
2021-09-29 23:19:51 +00:00
test("splits empty path", () => {
expect(
parsePath("/"),
2021-09-29 23:19:51 +00:00
).toMatchObject(
{}
)
})
test("splits instance path", () => {
expect(
parsePath("/i/https:api:sophon:steffo:eu:"),
2021-09-29 23:19:51 +00:00
).toMatchObject(
{
instance: "https:api:sophon:steffo:eu:"
}
)
})
test("splits username path", () => {
expect(
parsePath("/i/https:api:sophon:steffo:eu:/u/steffo"),
2021-09-29 23:19:51 +00:00
).toMatchObject(
{
instance: "https:api:sophon:steffo:eu:",
userName: "steffo",
}
)
})
test("splits userid path", () => {
expect(
parsePath("/i/https:api:sophon:steffo:eu:/u/1"),
2021-09-29 23:19:51 +00:00
).toMatchObject(
{
instance: "https:api:sophon:steffo:eu:",
userId: "1",
}
)
})
test("splits research group path", () => {
expect(
parsePath("/i/https:api:sophon:steffo:eu:/g/testers"),
2021-09-29 23:19:51 +00:00
).toMatchObject(
{
instance: "https:api:sophon:steffo:eu:",
researchGroup: "testers",
}
)
})
test("splits research project path", () => {
expect(
parsePath("/i/https:api:sophon:steffo:eu:/g/testers/p/test"),
2021-09-29 23:19:51 +00:00
).toMatchObject(
{
instance: "https:api:sophon:steffo:eu:",
researchGroup: "testers",
researchProject: "test",
}
)
})
test("splits research project path", () => {
expect(
parsePath("/i/https:api:sophon:steffo:eu:/g/testers/p/test/n/testerino"),
2021-09-29 23:19:51 +00:00
).toMatchObject(
{
instance: "https:api:sophon:steffo:eu:",
researchGroup: "testers",
researchProject: "test",
notebook: "testerino",
}
)
})