Skip to content

Commit ac636f8

Browse files
committed
Data: Isolate registerGenericStore warning tests
1 parent a11bd54 commit ac636f8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/data/src/test/registry.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2+
import { logged } from '@wordpress/deprecated';
23
import { createRegistry } from '../registry';
34
import { createRegistrySelector } from '../factory';
45
import createReduxStore from '../redux-store';
56
import coreDataStore from '../store';
67

8+
const REGISTER_GENERIC_STORE_DEPRECATION =
9+
'wp.data.registerGenericStore is deprecated since version 5.9. Please use wp.data.register( storeDescriptor ) instead.';
10+
711
describe( 'createRegistry', () => {
812
let registry;
913

@@ -27,6 +31,7 @@ describe( 'createRegistry', () => {
2731

2832
beforeEach( () => {
2933
vi.useFakeTimers();
34+
logged[ REGISTER_GENERIC_STORE_DEPRECATION ] = true;
3035
registry = createRegistry();
3136
} );
3237

@@ -35,6 +40,7 @@ describe( 'createRegistry', () => {
3540
while ( ( unsubscribe = unsubscribes.shift() ) ) {
3641
unsubscribe();
3742
}
43+
delete logged[ REGISTER_GENERIC_STORE_DEPRECATION ];
3844
vi.useRealTimers();
3945
} );
4046

@@ -50,6 +56,7 @@ describe( 'createRegistry', () => {
5056
} );
5157

5258
it( 'should throw if not all required config elements are present', () => {
59+
delete logged[ REGISTER_GENERIC_STORE_DEPRECATION ];
5360
expect( () =>
5461
registry.registerGenericStore( 'grocer', {} )
5562
).toThrow();
@@ -65,7 +72,9 @@ describe( 'createRegistry', () => {
6572
subscribe,
6673
} )
6774
).toThrow();
68-
expect( console ).toHaveWarned();
75+
expect( console ).toHaveWarnedWith(
76+
REGISTER_GENERIC_STORE_DEPRECATION
77+
);
6978
} );
7079

7180
describe( 'getSelectors', () => {

0 commit comments

Comments
 (0)