File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -66,11 +66,14 @@ class Hook {
6666 _tap ( type , options , fn ) {
6767 if ( typeof options === "string" ) {
6868 options = {
69- name : options . trim ( )
69+ name : options
7070 } ;
7171 } else if ( typeof options !== "object" || options === null ) {
7272 throw new Error ( "Invalid tap options" ) ;
7373 }
74+ if ( typeof options . name === "string" ) {
75+ options . name = options . name . trim ( ) ;
76+ }
7477 if ( typeof options . name !== "string" || options . name === "" ) {
7578 throw new Error ( "Missing name for tap" ) ;
7679 }
Original file line number Diff line number Diff line change @@ -100,5 +100,11 @@ describe("Hook", () => {
100100 expect ( ( ) => hook . tap ( " " , ( ) => { } ) ) . toThrow (
101101 new Error ( "Missing name for tap" )
102102 ) ;
103+ expect ( ( ) => hook . tap ( { name : "" } , ( ) => { } ) ) . toThrow (
104+ new Error ( "Missing name for tap" )
105+ ) ;
106+ expect ( ( ) => hook . tap ( { name : " " } , ( ) => { } ) ) . toThrow (
107+ new Error ( "Missing name for tap" )
108+ ) ;
103109 } ) ;
104110} ) ;
You can’t perform that action at this time.
0 commit comments