Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/data/src/test/registry.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { logged } from '@wordpress/deprecated';
import { createRegistry } from '../registry';
import { createRegistrySelector } from '../factory';
import createReduxStore from '../redux-store';
import coreDataStore from '../store';

const REGISTER_GENERIC_STORE_DEPRECATION =
'wp.data.registerGenericStore is deprecated since version 5.9. Please use wp.data.register( storeDescriptor ) instead.';

describe( 'createRegistry', () => {
let registry;

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

beforeEach( () => {
vi.useFakeTimers();
logged[ REGISTER_GENERIC_STORE_DEPRECATION ] = true;
registry = createRegistry();
} );

Expand All @@ -35,6 +40,7 @@ describe( 'createRegistry', () => {
while ( ( unsubscribe = unsubscribes.shift() ) ) {
unsubscribe();
}
delete logged[ REGISTER_GENERIC_STORE_DEPRECATION ];
vi.useRealTimers();
} );

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

it( 'should throw if not all required config elements are present', () => {
delete logged[ REGISTER_GENERIC_STORE_DEPRECATION ];
expect( () =>
registry.registerGenericStore( 'grocer', {} )
).toThrow();
Expand All @@ -65,7 +72,9 @@ describe( 'createRegistry', () => {
subscribe,
} )
).toThrow();
expect( console ).toHaveWarned();
expect( console ).toHaveWarnedWith(
REGISTER_GENERIC_STORE_DEPRECATION
);
} );

describe( 'getSelectors', () => {
Expand Down
Loading