solve any problem (#248)

This commit is contained in:
tmshv authored and GitHub committed 2026-02-08 12:22:52 +07:00
1 parent 6da5a7a07b
commit 562b4f6408
9 files changed
+27 -16

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ export type FileCardProps = FileTokenData & {
}
export const FileCard: React.FC<FileCardProps> = props => {
const fileSize = size(props.file_size)
const fileSize = props.file_size != null ? size(props.file_size) : ""
const format = ext(props.file_format)
return (
+1 -1
View File
@@ -32,7 +32,7 @@ export const Gosuslugi: React.FC<GosuslugiProps> = () => {
}
// This call taken from getCode <script>Widget("https://pos.gosuslugi.ru/form", 312519)</script>
(window as any).Widget("https://pos.gosuslugi.ru/form", 312519)
window.Widget("https://pos.gosuslugi.ru/form", 312519)
})
return () => {
+3
View File
@@ -0,0 +1,3 @@
interface Window {
Widget(url: string, id: number): void
}
+1
View File
@@ -26,6 +26,7 @@ describe("size", () => {
it("should return empty string for non-finite values", () => {
expect(size(Infinity)).toBe("")
expect(size(-Infinity)).toBe("")
})
it("should format bytes", () => {
+2 -2
View File
@@ -14,8 +14,8 @@ export function ext(mimeType: string): string {
return mimeType
}
export function size(bytes: any, precision = 1): string {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return ""
export function size(bytes: number, precision = 1): string {
if (Number.isNaN(bytes) || !Number.isFinite(bytes)) return ""
const number = Math.floor(Math.log(bytes) / Math.log(1024))
const size = (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision)
+1 -7
View File
@@ -24,7 +24,7 @@ export type FileDefinition = {
cover?: Pic
file: {
name: string
size: string
size: number
type: string
src: string
}
@@ -77,12 +77,6 @@ export interface IMeta {
twitterCreator: string
}
export interface IImage {
alt: string
src: string
srcSet: Array<{ url: string, density: number }>
set: any // TODO
}
export interface ITag {
id: number
+8
View File
@@ -25,6 +25,14 @@ describe("Button", () => {
expect(onClick).toHaveBeenCalledWith("test-value", expect.anything())
})
it("calls onClick with undefined when no value is provided", () => {
const onClick = vi.fn()
render(<Button onClick={onClick}>Press</Button>)
fireEvent.click(screen.getByRole("button", { name: "Press" }))
expect(onClick).toHaveBeenCalledOnce()
expect(onClick).toHaveBeenCalledWith(undefined, expect.anything())
})
it("applies disabled class when disabled is true", () => {
const { container } = render(<Button disabled>Disabled</Button>)
expect(container.firstElementChild!.className).toMatch(/disabled/)
+2 -2
View File
@@ -18,13 +18,13 @@ const themeClass = {
export type ButtonProps = {
children?: React.ReactNode
value?: any
value?: string
style?: React.CSSProperties
href?: string
theme?: "default" | "ghost" | "icon"
size?: "default" | "small"
disabled?: boolean
onClick?: (value: any, event: MouseEvent) => void
onClick?: (value: string | undefined, event: MouseEvent) => void
}
export const Button: React.FC<ButtonProps> = ({ size = "default", theme = "default", disabled = false, ...props }) => {