-
Notifications
You must be signed in to change notification settings - Fork 943
chore: updated documentation link #1387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,17 @@ const renderAndClick = async (props: Partial<UserDropdownProps> = {}) => { | |
} | ||
|
||
describe("UserDropdown", () => { | ||
const env = process.env | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
process.env = { ...env } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since env is already receiving the process.env in line 14, I would guess we are doing this to clone the object, is that right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right - I don't want to mutate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If makes sense, I just would add a comment about this. |
||
}) | ||
|
||
afterEach(() => { | ||
process.env = env | ||
}) | ||
|
||
describe("when the trigger is clicked", () => { | ||
it("opens the menu", async () => { | ||
await renderAndClick() | ||
|
@@ -32,14 +43,15 @@ describe("UserDropdown", () => { | |
}) | ||
|
||
it("has the correct link for the documentation item", async () => { | ||
process.env.CODER_VERSION = "v0.5.4" | ||
await renderAndClick() | ||
|
||
const link = screen.getByText(Language.docsLabel).closest("a") | ||
if (!link) { | ||
throw new Error("Anchor tag not found for the documentation menu item") | ||
} | ||
|
||
expect(link.getAttribute("href")).toBe("https://coder.com/docs") | ||
expect(link.getAttribute("href")).toBe(`https://github.com/coder/coder/tree/${process.env.CODER_VERSION}/docs`) | ||
}) | ||
|
||
it("has the correct link for the account item", async () => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we need this, I'm not seeing a module being mocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've actually never mocked out
process.env
before so I'm definitely following some internet advice here 😃 but looking at the Jest docs, seems like each test file gets its own module registry by default. Trying to reset the cache with this line so we don't get any conflicts. I can test and see if it's not needed but it might be safer to leave it in. LMK what you think!Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not needed, I think we should remove it, but if you think it is needed, I'm good to keep it. I'm good with the decision you feel is the best 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure; we can always add it back in if we see conflicts.