Skip to content

Commit

Permalink
Add a couple more test for path stripping behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Oct 3, 2023
1 parent c2cf3d5 commit e976900
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions js/packages/binderhub-client/lib/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,58 @@ test("Get full redirect URL when opening a file with classic notebook (with file
.toString()
).toBe("https://hub.test-binder.org/user/something/tree/index.ipynb?token=token");
});

test("Get full redirect URL and deal with excessive slashes (with pathType=url)", () => {
const br = new BinderRepository(
"gh/test/test",
new URL("https://test-binder.org/build")
);
expect(
br
.getFullRedirectURL(
// Trailing slash should not be preserved here
"https://hub.test-binder.org/user/something/",
"token",
// Trailing slash should be preserved here, but leading slash should not be repeated
"/rstudio/",
"url"
)
.toString()
).toBe("https://hub.test-binder.org/user/something/rstudio/?token=token");
});

test("Get full redirect URL and deal with excessive slashes (with pathType=lab)", () => {
const br = new BinderRepository(
"gh/test/test",
new URL("https://test-binder.org/build")
);
expect(
br
.getFullRedirectURL(
"https://hub.test-binder.org/user/something/",
"token",
// Both leading and trailing slashes should be gone here.
"/directory/index.ipynb/",
"lab"
)
.toString()
).toBe("https://hub.test-binder.org/user/something/doc/tree/directory/index.ipynb?token=token");
});

test("Get full redirect URL and deal with excessive slashes (with pathType=file)", () => {
const br = new BinderRepository(
"gh/test/test",
new URL("https://test-binder.org/build")
);
expect(
br
.getFullRedirectURL(
"https://hub.test-binder.org/user/something/",
"token",
// Both leading and trailing slashes should be gone here.
"/directory/index.ipynb/",
"file"
)
.toString()
).toBe("https://hub.test-binder.org/user/something/tree/directory/index.ipynb?token=token");
});

0 comments on commit e976900

Please sign in to comment.