@wordpress/core-commands 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/admin-navigation-commands.js +6 -15
- package/build/admin-navigation-commands.js.map +1 -1
- package/build/hooks.js +8 -8
- package/build/hooks.js.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +1 -5
- package/build/private-apis.js.map +1 -1
- package/build/site-editor-navigation-commands.js +49 -42
- package/build/site-editor-navigation-commands.js.map +1 -1
- package/build/utils/order-entity-records-by-search.js +26 -0
- package/build/utils/order-entity-records-by-search.js.map +1 -0
- package/build-module/admin-navigation-commands.js +7 -8
- package/build-module/admin-navigation-commands.js.map +1 -1
- package/build-module/hooks.js +5 -3
- package/build-module/hooks.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/site-editor-navigation-commands.js +51 -34
- package/build-module/site-editor-navigation-commands.js.map +1 -1
- package/build-module/utils/order-entity-records-by-search.js +20 -0
- package/build-module/utils/order-entity-records-by-search.js.map +1 -0
- package/package.json +14 -13
- package/src/admin-navigation-commands.js +6 -5
- package/src/hooks.js +9 -6
- package/src/site-editor-navigation-commands.js +51 -16
- package/src/utils/order-entity-records-by-search.js +25 -0
- package/src/utils/test/order-entity-records-by-search.js +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { orderEntityRecordsBySearch } from '../order-entity-records-by-search';
|
|
5
|
+
|
|
6
|
+
const mockData = [
|
|
7
|
+
{
|
|
8
|
+
title: {
|
|
9
|
+
raw: 'Category',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
title: {
|
|
14
|
+
raw: 'Archive',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: {
|
|
19
|
+
raw: 'Single',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: {
|
|
24
|
+
raw: 'Single Product',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: {
|
|
29
|
+
raw: 'Order Confirmation',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
describe( 'orderEntityRecordsBySearch', () => {
|
|
35
|
+
it( 'should return an empty array if no records are passed', () => {
|
|
36
|
+
expect( orderEntityRecordsBySearch( [], '' ) ).toEqual( [] );
|
|
37
|
+
expect( orderEntityRecordsBySearch( null, '' ) ).toEqual( [] );
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
it( 'should correctly order records by search', () => {
|
|
41
|
+
const singleResult = orderEntityRecordsBySearch( mockData, 'Single' );
|
|
42
|
+
const singleProductResult = orderEntityRecordsBySearch(
|
|
43
|
+
mockData,
|
|
44
|
+
'Single Product'
|
|
45
|
+
);
|
|
46
|
+
const categoryResult = orderEntityRecordsBySearch(
|
|
47
|
+
mockData,
|
|
48
|
+
'Category'
|
|
49
|
+
);
|
|
50
|
+
const orderResult = orderEntityRecordsBySearch( mockData, 'Order' );
|
|
51
|
+
|
|
52
|
+
expect( singleResult.map( ( { title } ) => title.raw ) ).toEqual( [
|
|
53
|
+
'Single',
|
|
54
|
+
'Single Product',
|
|
55
|
+
'Category',
|
|
56
|
+
'Archive',
|
|
57
|
+
'Order Confirmation',
|
|
58
|
+
] );
|
|
59
|
+
expect( singleProductResult.map( ( { title } ) => title.raw ) ).toEqual(
|
|
60
|
+
[
|
|
61
|
+
'Single Product',
|
|
62
|
+
'Category',
|
|
63
|
+
'Archive',
|
|
64
|
+
'Single',
|
|
65
|
+
'Order Confirmation',
|
|
66
|
+
]
|
|
67
|
+
);
|
|
68
|
+
expect( categoryResult.map( ( { title } ) => title.raw ) ).toEqual( [
|
|
69
|
+
'Category',
|
|
70
|
+
'Archive',
|
|
71
|
+
'Single',
|
|
72
|
+
'Single Product',
|
|
73
|
+
'Order Confirmation',
|
|
74
|
+
] );
|
|
75
|
+
expect( orderResult.map( ( { title } ) => title.raw ) ).toEqual( [
|
|
76
|
+
'Order Confirmation',
|
|
77
|
+
'Category',
|
|
78
|
+
'Archive',
|
|
79
|
+
'Single',
|
|
80
|
+
'Single Product',
|
|
81
|
+
] );
|
|
82
|
+
} );
|
|
83
|
+
} );
|