-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(suite): enforce that the Security Check List icon is NOT just a s…
…tring (#16709)
- Loading branch information
1 parent
bc14291
commit 5d28e7b
Showing
3 changed files
with
37 additions
and
8 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
26 changes: 26 additions & 0 deletions
26
packages/suite/src/views/onboarding/steps/SecurityCheck/__tests__/types.test.tsx
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,26 @@ | ||
import { Icon } from '@trezor/components'; | ||
|
||
import { SecurityChecklistItem } from '../types'; | ||
|
||
describe('SecurityChecklistItem', () => { | ||
describe('type tests', () => { | ||
it("should not accept icon: 'string' as an icon prop", () => { | ||
const x: SecurityChecklistItem = { | ||
// @ts-expect-error: this should correctly throw a TS error - it cannot be a string | ||
icon: 'string', | ||
content: <div />, | ||
}; | ||
|
||
expect(x).toBeTruthy(); | ||
}); | ||
|
||
it('should accept icon: ReactElement<<Icon />> as an icon prop', () => { | ||
const x: SecurityChecklistItem = { | ||
icon: <Icon name="hologram" />, | ||
content: <div />, | ||
}; | ||
|
||
expect(x).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
6 changes: 4 additions & 2 deletions
6
packages/suite/src/views/onboarding/steps/SecurityCheck/types.ts
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { ReactNode } from 'react'; | ||
import { ReactElement, ReactNode } from 'react'; | ||
|
||
import { Icon, IconProps } from '@trezor/components'; | ||
|
||
export type SecurityChecklistItem = { | ||
icon: ReactNode; | ||
icon: ReactElement<IconProps, typeof Icon>; | ||
content: ReactNode; | ||
subtitle?: ReactNode; | ||
}; |