@@ -547,6 +547,47 @@ describe("core.dom tests", () => {
547
547
} ) ;
548
548
} ) ;
549
549
550
+ describe ( "is_button" , ( ) => {
551
+ it ( "checks, if an element is a button-like element or not." , ( done ) => {
552
+
553
+ const button = document . createElement ( "button" ) ;
554
+ const button_button = document . createElement ( "button" ) ;
555
+ button_button . setAttribute ( "type" , "button" ) ;
556
+ const button_submit = document . createElement ( "button" ) ;
557
+ button_submit . setAttribute ( "type" , "submit" ) ;
558
+
559
+ const input_button = document . createElement ( "input" ) ;
560
+ input_button . setAttribute ( "type" , "button" ) ;
561
+ const input_submit = document . createElement ( "input" ) ;
562
+ input_submit . setAttribute ( "type" , "submit" ) ;
563
+ const input_reset = document . createElement ( "input" ) ;
564
+ input_reset . setAttribute ( "type" , "reset" ) ;
565
+ const input_image = document . createElement ( "input" ) ;
566
+ input_image . setAttribute ( "type" , "image" ) ;
567
+
568
+ expect ( dom . is_button ( button ) ) . toBe ( true ) ;
569
+ expect ( dom . is_button ( button_button ) ) . toBe ( true ) ;
570
+ expect ( dom . is_button ( button_submit ) ) . toBe ( true ) ;
571
+ expect ( dom . is_button ( input_button ) ) . toBe ( true ) ;
572
+ expect ( dom . is_button ( input_image ) ) . toBe ( true ) ;
573
+ expect ( dom . is_button ( input_reset ) ) . toBe ( true ) ;
574
+ expect ( dom . is_button ( input_submit ) ) . toBe ( true ) ;
575
+
576
+ const input_text = document . createElement ( "input" ) ;
577
+ input_text . setAttribute ( "type" , "text" ) ;
578
+
579
+ expect ( dom . is_button ( input_text ) ) . toBe ( false ) ;
580
+ expect ( dom . is_button ( document . createElement ( "input" ) ) ) . toBe ( false ) ;
581
+ expect ( dom . is_button ( document . createElement ( "select" ) ) ) . toBe ( false ) ;
582
+ expect ( dom . is_button ( document . createElement ( "textarea" ) ) ) . toBe ( false ) ;
583
+ expect ( dom . is_button ( document . createElement ( "form" ) ) ) . toBe ( false ) ;
584
+ expect ( dom . is_button ( document . createElement ( "div" ) ) ) . toBe ( false ) ;
585
+
586
+ done ( ) ;
587
+ } ) ;
588
+ } ) ;
589
+
590
+
550
591
describe ( "create_from_string" , ( ) => {
551
592
it ( "Creates a DOM element from a string" , ( done ) => {
552
593
const res = dom . create_from_string ( `
0 commit comments