forked from sigstore/rekor-search-ui
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(unit): fix issue with base64 encoding & additional coverage
test(unit): restore mock test(unit): fix issue with base64 encoding and context minor changes fix issue with base64 encoding re-enable hashed rekord test fix test for HashedRekord component fix breaking Entry test add mocks for explorer test add mocks for explorer test add data-testids and additional tests for explorer fix tests, add additional fix lint issue
- Loading branch information
Showing
10 changed files
with
250 additions
and
54 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
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,57 @@ | ||
const originalEnv = process.env; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
process.env = { | ||
...originalEnv, | ||
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "https://example.com", | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env = originalEnv; | ||
}); | ||
|
||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { | ||
RekorClientProvider, | ||
useRekorClient, | ||
useRekorBaseUrl, | ||
} from "./context"; | ||
|
||
const TestConsumerComponent = () => { | ||
useRekorClient(); | ||
const [baseUrl, setBaseUrl] = useRekorBaseUrl(); | ||
|
||
return ( | ||
<div> | ||
<button onClick={() => setBaseUrl("https://new.example.com")}> | ||
Change Base URL | ||
</button> | ||
<p>Base URL: {baseUrl}</p> | ||
</div> | ||
); | ||
}; | ||
|
||
describe("RekorClientContext", () => { | ||
beforeAll(() => jest.clearAllMocks()); | ||
|
||
it("provides a RekorClient instance and manages base URL", async () => { | ||
render( | ||
<RekorClientProvider> | ||
<TestConsumerComponent /> | ||
</RekorClientProvider>, | ||
); | ||
|
||
expect( | ||
screen.getByText(/Base URL: https:\/\/example.com/), | ||
).toBeInTheDocument(); | ||
|
||
await userEvent.click(screen.getByText(/Change Base URL/)); | ||
|
||
expect( | ||
screen.getByText(/Base URL: https:\/\/new.example.com/), | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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
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.