@wordpress/hooks
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "@wordpress/hooks", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "WordPress Hooks library", | ||
"author": "WordPress", | ||
"license": "GPL-2.0+", | ||
"license": "GPL-2.0-or-later", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "hooks" |
@@ -26,3 +26,3 @@ /* eslint-disable no-console */ | ||
filters, | ||
} from '../'; | ||
} from '..'; | ||
@@ -68,4 +68,2 @@ function filter_a( str ) { | ||
const consoleErrorOriginal = console.error; | ||
beforeEach( () => { | ||
@@ -81,9 +79,4 @@ window.actionValue = ''; | ||
} ); | ||
console.error = jest.fn(); | ||
} ); | ||
afterEach( () => { | ||
console.error = consoleErrorOriginal; | ||
} ); | ||
test( 'hooks can be instantiated', () => { | ||
@@ -124,3 +117,3 @@ const hooks = createHooks(); | ||
expect( removeFilter( 'test.filter', 42 ) ).toBe( undefined ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The namespace must be a non-empty string.' | ||
@@ -132,3 +125,3 @@ ); | ||
addFilter( 42, 'my_callback', () => null ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The hook name must be a non-empty string.' | ||
@@ -140,3 +133,3 @@ ); | ||
addFilter( '', 'my_callback', () => null ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The hook name must be a non-empty string.' | ||
@@ -148,3 +141,3 @@ ); | ||
addFilter( 'hook_name', '', () => null ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The namespace must be a non-empty string.' | ||
@@ -156,3 +149,3 @@ ); | ||
addFilter( 'hook_name', 'invalid_%&name', () => null ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.' | ||
@@ -164,3 +157,3 @@ ); | ||
addFilter( 'hook_name', 'with-dashes', () => null ); | ||
expect( console.error ).toHaveBeenCalledTimes( 0 ); | ||
expect( console ).not.toHaveErrored(); | ||
} ); | ||
@@ -170,3 +163,3 @@ | ||
addFilter( 'hook_name', 'My_Name-OhNoaction', () => null ); | ||
expect( console.error ).toHaveBeenCalledTimes( 0 ); | ||
expect( console ).not.toHaveErrored(); | ||
} ); | ||
@@ -176,3 +169,3 @@ | ||
addFilter( 'hook_name', 'my/name/action', () => null ); | ||
expect( console.error ).toHaveBeenCalledTimes( 0 ); | ||
expect( console ).not.toHaveErrored(); | ||
} ); | ||
@@ -182,3 +175,3 @@ | ||
addFilter( 'hook_name', 'my.name.action', () => null ); | ||
expect( console.error ).toHaveBeenCalledTimes( 0 ); | ||
expect( console ).not.toHaveErrored(); | ||
} ); | ||
@@ -188,3 +181,3 @@ | ||
addFilter( 'hookName', 'action', () => null ); | ||
expect( console.error ).toHaveBeenCalledTimes( 0 ); | ||
expect( console ).not.toHaveErrored(); | ||
} ); | ||
@@ -194,3 +187,3 @@ | ||
addFilter( 'hook_name', 'ok.action', () => null ); | ||
expect( console.error ).toHaveBeenCalledTimes( 0 ); | ||
expect( console ).not.toHaveErrored(); | ||
} ); | ||
@@ -200,3 +193,3 @@ | ||
addFilter( 'hook.name', 'action', () => null ); | ||
expect( console.error ).toHaveBeenCalledTimes( 0 ); | ||
expect( console ).not.toHaveErrored(); | ||
} ); | ||
@@ -206,3 +199,3 @@ | ||
addFilter( 'hook_name', '/invalid_name', () => null ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.' | ||
@@ -214,3 +207,3 @@ ); | ||
addFilter( 'hook_name', 'i\n\v\a\l\i\d\n\a\m\e', () => null ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.' | ||
@@ -222,3 +215,3 @@ ); | ||
addFilter( '__test', 'my_callback', () => null ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The hook name cannot begin with `__`.' | ||
@@ -230,3 +223,3 @@ ); | ||
addFilter( 'test', 'my_callback', '42' ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The hook callback must be a function.' | ||
@@ -238,3 +231,3 @@ ); | ||
addFilter( 'test', 'my_callback', () => null, '42' ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'If specified, the hook priority must be a number.' | ||
@@ -246,3 +239,3 @@ ); | ||
expect( applyFilters( () => {}, 42 ) ).toBe( undefined ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The hook name must be a non-empty string.' | ||
@@ -254,3 +247,3 @@ ); | ||
expect( applyFilters( '__test', 42 ) ).toBe( undefined ); | ||
expect( console.error ).toHaveBeenCalledWith( | ||
expect( console ).toHaveErroredWith( | ||
'The hook name cannot begin with `__`.' | ||
@@ -360,3 +353,3 @@ ); | ||
expect( true ).toBe( true ); | ||
}; | ||
} | ||
@@ -603,3 +596,3 @@ addAction( 'test.action', 'my_callback', func ); | ||
val += '-' + applyFilters( 'remove_and_add', '' ) + '-'; | ||
addFilter( 'remove_and_add', 'my_callback_recurse', 10 ); | ||
addFilter( 'remove_and_add', 'my_callback_recurse', removeRecurseAndAdd2, 10 ); | ||
return val + '2'; | ||
@@ -641,3 +634,3 @@ } | ||
}; | ||
addAction( 'test.action', 'my_callback', theCallback.apply( testObject ) ); | ||
addAction( 'test.action', 'my_callback', theCallback.bind( testObject ) ); | ||
doAction( 'test.action' ); | ||
@@ -644,0 +637,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
0
69148
1850