File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 11import { customEditors } from "./CustomEditors.js" ;
22
3+ const mockConsoleError = jest
4+ . spyOn ( console , "error" )
5+ . mockImplementation ( ( ) => void 0 ) ;
6+
37describe ( "CustomEditors" , ( ) => {
48 it ( "should work" , ( ) => {
59 function objectEntries ( object : Record < string , any > ) : [ string , any ] [ ] {
@@ -20,9 +24,11 @@ describe("CustomEditors", () => {
2024 ) . toEqual ( [ [ "quality" , "good" ] ] ) ;
2125 expect ( customEditors . get ( "basic-bricks.general-button-editor" ) ?.( ) ) . toBe ( 5 ) ;
2226
27+ expect ( mockConsoleError ) . toHaveBeenCalledTimes ( 0 ) ;
28+
2329 // Can't register duplicated editors in the same namespace.
24- expect ( ( ) => {
25- customEditors . define ( "eo-button--editor" , ( ) => void 0 ) ;
26- } ) . toThrowError ( ) ;
30+ customEditors . define ( "eo-button--editor" , ( ) => void 0 ) ;
31+
32+ expect ( mockConsoleError ) . toHaveBeenCalledTimes ( 1 ) ;
2733 } ) ;
2834} ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ class CustomEditorRegistry {
33
44 define ( editorName : string , editorFunc : Function ) {
55 if ( this . #registry. has ( editorName ) ) {
6- throw new Error ( `Custom editor of "${ editorName } " already registered` ) ;
6+ // eslint-disable-next-line no-console
7+ console . error ( `Custom editor of "${ editorName } " already registered` ) ;
8+ return ;
79 }
810
911 this . #registry. set ( editorName , editorFunc ) ;
You can’t perform that action at this time.
0 commit comments