@@ -22,20 +22,32 @@ import { KeyComboTagInternal } from "../../src/components/hotkeys/keyComboTag";
2222
2323describe ( "KeyCombo" , ( ) => {
2424 it ( "renders key combo" , ( ) => {
25- render ( < KeyComboTagInternal combo = "cmd+C" platformOverride = "Mac" /> ) ;
26- expect ( screen . getByText ( "C" ) ) . not . to . be . undefined ;
25+ const { container } = render ( < KeyComboTagInternal combo = "cmd+C" platformOverride = "Mac" /> ) ;
26+ const icon = container . querySelector ( '[data-icon="key-command"]' ) ;
27+
28+ expect ( icon ) . to . exist ;
29+ expect ( screen . getByText ( "cmd" ) ) . to . exist ;
30+ expect ( screen . getByText ( "C" ) ) . to . exist ;
2731 } ) ;
2832
2933 it ( "should render minimal key combos on Mac using icons" , ( ) => {
3034 render ( < KeyComboTagInternal combo = "mod+C" minimal = { true } platformOverride = "Mac" /> ) ;
31- expect ( ( ) => screen . getByText ( "cmd + C" , { exact : false } ) ) . to . throw ;
35+
36+ expect ( screen . getByText ( "C" ) ) . to . exist ;
37+ expect ( screen . queryByText ( "ctrl" ) ) . to . not . exist ;
3238 } ) ;
3339
3440 it ( "should render minimal key combos on non-Macs using text" , ( ) => {
3541 render ( < KeyComboTagInternal combo = "mod+C" minimal = { true } platformOverride = "Win32" /> ) ;
36- const text = screen . getByText ( "ctrl + C" , { exact : false } ) . innerText ;
37- expect ( text ) . to . contain ( "ctrl" ) ;
38- expect ( text ) . to . contain ( "+" ) ;
39- expect ( text ) . to . contain ( "C" ) ;
42+
43+ expect ( screen . getByText ( "ctrl + C" ) ) . to . exist ;
44+ } ) ;
45+
46+ it ( "should render aliased keys with correct icon and text" , ( ) => {
47+ const { container } = render ( < KeyComboTagInternal combo = "arrowleft" /> ) ;
48+ const icon = container . querySelector ( '[data-icon="arrow-left"]' ) ;
49+
50+ expect ( icon ) . to . exist ;
51+ expect ( screen . getByText ( "left" ) ) . to . exist ;
4052 } ) ;
4153} ) ;
0 commit comments