generated from cloud-gov/.github
-
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 branch 'main' into 409/org-selection-component
Signed-off-by: Claire Annan <[email protected]>
- Loading branch information
Showing
29 changed files
with
1,013 additions
and
265 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ CF_API_TOKEN= | |
# Prefixing a variable with NEXT_PUBLIC_ will make it available to the browser: | ||
# https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser | ||
NEXT_PUBLIC_USER_INVITE_URL=https://account.dev.us-gov-west-1.aws-us-gov.cloud.gov/invite | ||
NEXT_PUBLIC_CLOUD_SUPPORT_URL="mailto:[email protected]?body=What+is+your+question%3F%0D%0A%0D%0APlease+provide+your+application+name+or+URL.+Do+not+include+any+sensitive+information+about+your+platform+in+this+email." |
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,75 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { jest, describe, expect, it, beforeAll } from '@jest/globals'; | ||
import { OverlayDrawer } from '@/components/OverlayDrawer'; | ||
import { render, screen, waitFor, fireEvent } from '@testing-library/react'; | ||
|
||
describe('<OverlayDrawer />', () => { | ||
beforeAll(() => { | ||
HTMLDialogElement.prototype.show = jest.fn(function () { | ||
this.open = true; | ||
}); | ||
|
||
HTMLDialogElement.prototype.showModal = jest.fn(function () { | ||
this.open = true; | ||
}); | ||
|
||
HTMLDialogElement.prototype.close = jest.fn(function () { | ||
this.open = false; | ||
}); | ||
}); | ||
|
||
it('shows dialog content when opened', async () => { | ||
// render | ||
render( | ||
<OverlayDrawer id="overlay-drawer-1" isOpen={true} close={() => {}}> | ||
This is the drawer content. | ||
</OverlayDrawer> | ||
); | ||
// assert | ||
await waitFor(() => { | ||
expect(screen.getByText(/This is the drawer content./i)).toBeVisible(); | ||
}); | ||
}); | ||
|
||
it('hides dialog content when closed', async () => { | ||
// render | ||
render( | ||
<OverlayDrawer id="overlay-drawer-1" isOpen={false} close={() => {}}> | ||
This is the drawer content. | ||
</OverlayDrawer> | ||
); | ||
// assert | ||
await waitFor(() => { | ||
expect( | ||
screen.getByText(/This is the drawer content./i) | ||
).not.toBeVisible(); | ||
}); | ||
}); | ||
|
||
it('calls the close() prop when using the Escape key to close', async () => { | ||
// setup | ||
const close = jest.fn(); | ||
// render | ||
render( | ||
<OverlayDrawer id="overlay-drawer-1" isOpen={true} close={close}> | ||
This is the drawer content. | ||
</OverlayDrawer> | ||
); | ||
// query | ||
const content = screen.getByText(/This is the drawer content./); | ||
expect(content).toBeInTheDocument(); | ||
// act = press escape key | ||
await waitFor(() => { | ||
fireEvent.keyDown(content, { | ||
key: 'Escape', | ||
code: 'Escape', | ||
keyCode: 27, | ||
charCode: 27, | ||
}); | ||
}); | ||
// assert | ||
expect(close).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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
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
Oops, something went wrong.