-
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.
- Loading branch information
Showing
11 changed files
with
1,567 additions
and
17,978 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no -- commitlint --edit ${1} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
module.exports = { extends: ['@commitlint/config-conventional'] }; |
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 |
---|---|---|
|
@@ -3,39 +3,33 @@ import AddKeyForm from "." | |
import * as otpauth from "otpauth" | ||
import { useKey } from "@/components/context/keyProvider"; | ||
|
||
const mockGetUserMedia = jest.fn(async () => { | ||
return new Promise<void>((resolve) => { | ||
resolve(); | ||
}); | ||
}); | ||
|
||
Object.defineProperty(global.navigator, "mediaDevices", { | ||
value: { | ||
getUserMedia: mockGetUserMedia, | ||
}, | ||
}); | ||
|
||
describe("Add Key Form Component", () => { | ||
const url = | ||
"otpauth:https://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example"; | ||
const parsedUrl = otpauth.URI.parse(url) | ||
|
||
it("Adding a key using manual form", async () => { | ||
const element = render(<AddKeyForm />) | ||
|
||
const issuerForm = element.getByAltText("issuer") | ||
const labelForm = element.getByAltText("label"); | ||
const secretForm = element.getByAltText("secret"); | ||
const submitButton = element.getByRole("button", { | ||
name: "Add Key" | ||
}) | ||
|
||
fireEvent.change(issuerForm, { | ||
target: { | ||
value: parsedUrl.issuer | ||
} | ||
}) | ||
fireEvent.change(labelForm, { | ||
target: { | ||
value: parsedUrl.label, | ||
}, | ||
}); | ||
fireEvent.change(secretForm, { | ||
target: { | ||
value: parsedUrl.secret.base32, | ||
}, | ||
}); | ||
|
||
fireEvent.click(submitButton) | ||
|
||
const arraytemp: [] = JSON.parse(localStorage.getItem("key")!) | ||
it("on initial render, it should show the manual input form first", async () => { | ||
render(<AddKeyForm />) | ||
expect(screen.getByRole("heading")).toHaveTextContent("2FA Input Form") | ||
}) | ||
it("switching to scanner page", () => { | ||
render(<AddKeyForm />); | ||
fireEvent.click( | ||
screen.getByRole("button", { | ||
name: "Scan QR code", | ||
}) | ||
); | ||
}) | ||
}) |
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,25 @@ | ||
import React from 'react' | ||
|
||
interface InputInterface { | ||
type: React.HTMLInputTypeAttribute | undefined; | ||
placeholder?: string | undefined; | ||
required?: boolean | undefined; | ||
value?: string | number | readonly string[] | undefined; | ||
onChange?: React.ChangeEventHandler<HTMLInputElement> | undefined; | ||
alt?: string | undefined; | ||
} | ||
const Input = (props: InputInterface) => { | ||
return ( | ||
<input | ||
type={props.type} | ||
placeholder={props.placeholder} | ||
className="input input-bordered w-full" | ||
required={props.required} | ||
value={props.value} | ||
onChange={props.onChange} | ||
alt={props.alt} | ||
/> | ||
); | ||
} | ||
|
||
export default Input |
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,11 @@ | ||
import React from 'react' | ||
|
||
interface H1Interface { | ||
className?: string | undefined | ||
children: any | ||
} | ||
const H1 = (props: H1Interface) => { | ||
return <h1 className={"text-3xl font-bold " + props.className}>{props.children}</h1>; | ||
} | ||
|
||
export default H1 |
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,7 @@ | ||
import React from "react"; | ||
|
||
const H2 = ({ children }: any) => { | ||
return <h1 className="text-2xl font-bold">{children}</h1>; | ||
}; | ||
|
||
export default H2; |
Oops, something went wrong.