File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -1100,4 +1100,24 @@ describe(`getStore`, () => {
1100
1100
} ) ,
1101
1101
) . toThrowError ( MissingBlobsEnvironmentError )
1102
1102
} )
1103
+
1104
+ test ( 'Throws when the name of the store is not provided' , async ( ) => {
1105
+ const { fetch } = new MockFetch ( )
1106
+
1107
+ globalThis . fetch = fetch
1108
+
1109
+ // @ts -expect-error Ignoring types, which expect an argument
1110
+ expect ( ( ) => getStore ( ) ) . toThrowError (
1111
+ 'The `getStore` method requires the name of the store as a string or as the `name` property of an options object' ,
1112
+ )
1113
+
1114
+ expect ( ( ) =>
1115
+ getStore ( {
1116
+ token : apiToken ,
1117
+ siteID,
1118
+ } ) ,
1119
+ ) . toThrowError (
1120
+ 'The `getStore` method requires the name of the store as a string or as the `name` property of an options object' ,
1121
+ )
1122
+ } )
1103
1123
} )
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export const getStore: {
44
44
return new Store ( { client, name : input } )
45
45
}
46
46
47
- if ( typeof input . name === 'string' ) {
47
+ if ( typeof input ? .name === 'string' ) {
48
48
const { name } = input
49
49
const clientOptions = getClientOptions ( input )
50
50
@@ -57,7 +57,7 @@ export const getStore: {
57
57
return new Store ( { client, name } )
58
58
}
59
59
60
- if ( typeof input . deployID === 'string' ) {
60
+ if ( typeof input ? .deployID === 'string' ) {
61
61
const clientOptions = getClientOptions ( input )
62
62
const { deployID } = input
63
63
@@ -70,5 +70,7 @@ export const getStore: {
70
70
return new Store ( { client, deployID } )
71
71
}
72
72
73
- throw new Error ( '`getStore()` requires a `name` or `siteID` properties.' )
73
+ throw new Error (
74
+ 'The `getStore` method requires the name of the store as a string or as the `name` property of an options object' ,
75
+ )
74
76
}
You can’t perform that action at this time.
0 commit comments