@@ -74,7 +74,7 @@ describe('StorageClient Class Tests', () => {
74
74
env : {
75
75
CATALOG_BUCKET : {
76
76
get : sinon . stub ( ) . resolves ( {
77
- text : sinon . stub ( ) . resolves ( JSON . stringify ( { sku : 'sku1' , name : 'Test Product' } ) ) ,
77
+ json : sinon . stub ( ) . resolves ( { sku : 'sku1' , name : 'Test Product' } ) ,
78
78
} ) ,
79
79
} ,
80
80
} ,
@@ -86,7 +86,9 @@ describe('StorageClient Class Tests', () => {
86
86
87
87
assert ( ctx . log . debug . calledOnceWithExactly ( 'Fetching product from R2:' , 'org/site/store/view/products/sku1.json' ) ) ;
88
88
assert ( ctx . env . CATALOG_BUCKET . get . calledOnceWithExactly ( 'org/site/store/view/products/sku1.json' ) ) ;
89
- assert . deepStrictEqual ( product , { sku : 'sku1' , name : 'Test Product' } ) ;
89
+ assert . deepStrictEqual ( product , {
90
+ sku : 'sku1' , attributeMap : { } , name : 'Test Product' ,
91
+ } ) ;
90
92
} ) ;
91
93
92
94
it ( 'should throw 404 error if product not found' , async ( ) => {
@@ -117,33 +119,6 @@ describe('StorageClient Class Tests', () => {
117
119
assert . strictEqual ( thrownError , error ) ;
118
120
} ) ;
119
121
120
- it ( 'should throw error if JSON parsing fails' , async ( ) => {
121
- const ctx = {
122
- log : { debug : sinon . stub ( ) } ,
123
- env : {
124
- CATALOG_BUCKET : {
125
- get : sinon . stub ( ) . resolves ( {
126
- text : sinon . stub ( ) . resolves ( 'invalid json' ) ,
127
- } ) ,
128
- } ,
129
- } ,
130
- } ;
131
-
132
- const sku = 'sku1' ;
133
- const client = new StorageClient ( ctx , config ) ;
134
-
135
- let thrownError ;
136
- try {
137
- await client . fetchProduct ( sku ) ;
138
- } catch ( e ) {
139
- thrownError = e ;
140
- }
141
-
142
- assert ( ctx . log . debug . calledOnceWithExactly ( 'Fetching product from R2:' , 'org/site/store/view/products/sku1.json' ) ) ;
143
- assert ( ctx . env . CATALOG_BUCKET . get . calledOnceWithExactly ( 'org/site/store/view/products/sku1.json' ) ) ;
144
- assert ( thrownError instanceof SyntaxError ) ;
145
- } ) ;
146
-
147
122
it ( 'should propagate errors from CATALOG_BUCKET.get' , async ( ) => {
148
123
const ctx = {
149
124
log : { debug : sinon . stub ( ) } ,
0 commit comments