forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request galaxyproject#17426 from davelopez/23.1_encode_too…
…l_link_consistently [23.1] Encode tool link consistently
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { copyLink } from "./utilities"; | ||
|
||
const writeText = jest.fn(); | ||
|
||
Object.assign(navigator, { | ||
clipboard: { | ||
writeText, | ||
}, | ||
}); | ||
|
||
describe("copyLink", () => { | ||
beforeEach(() => { | ||
(navigator.clipboard.writeText as jest.Mock).mockResolvedValue(undefined); | ||
}); | ||
|
||
it("should copy the link to the clipboard", () => { | ||
const toolId = "MyToolId"; | ||
copyLink(toolId); | ||
expect(writeText).toHaveBeenCalledTimes(1); | ||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining(toolId)); | ||
}); | ||
|
||
it("should encode the tool id with spaces", () => { | ||
const toolId = "My Tool Id"; | ||
copyLink(toolId); | ||
expect(writeText).toHaveBeenCalledTimes(1); | ||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining("My%20Tool%20Id")); | ||
}); | ||
|
||
it("should not encode the character '+' in the tool id", () => { | ||
const toolId = "My Tool Id+1"; | ||
copyLink(toolId); | ||
expect(writeText).toHaveBeenCalledTimes(1); | ||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining("My%20Tool%20Id+1")); | ||
}); | ||
}); |