bv-ui-core 2.9.2 → 2.9.3
Sign up to get free protection for your applications and to get access to all the features.
package/lib/bvFetch/index.js
CHANGED
@@ -83,14 +83,15 @@ module.exports = function BvFetch ({ shouldCache, cacheName, cacheLimit }) {
|
|
83
83
|
}
|
84
84
|
}).then(() => {
|
85
85
|
if (canBeCached) {
|
86
|
-
const clonedResponse = response.clone()
|
86
|
+
const clonedResponse = response.clone();
|
87
|
+
const sizeCheck = response.clone();
|
87
88
|
const newHeaders = new Headers();
|
88
89
|
clonedResponse.headers.forEach((value, key) => {
|
89
90
|
newHeaders.append(key, value);
|
90
91
|
});
|
91
92
|
newHeaders.append('X-Bazaarvoice-Cached-Time', Date.now())
|
92
93
|
// Get response text to calculate its size
|
93
|
-
|
94
|
+
sizeCheck.text().then(text => {
|
94
95
|
// Calculate size of response text in bytes
|
95
96
|
const sizeInBytes = new Blob([text]).size;
|
96
97
|
|
package/package.json
CHANGED
@@ -140,16 +140,17 @@ describe('BvFetch', function () {
|
|
140
140
|
bvFetchInstance.bvFetchFunc(url, options)
|
141
141
|
.then(response => {
|
142
142
|
// Check if response is fetched from network
|
143
|
-
|
144
|
-
|
143
|
+
setTimeout(() => {
|
144
|
+
expect(response).to.not.be.null;
|
145
|
+
console.log(response.body)
|
145
146
|
|
146
147
|
// Check if caches.match was called
|
147
|
-
|
148
|
+
expect(cacheStub.calledOnce).to.be.false;
|
148
149
|
|
149
150
|
// Check if response is not cached
|
150
|
-
|
151
|
-
|
152
|
-
|
151
|
+
const cachedResponse = cacheStorage.get(url);
|
152
|
+
expect(cachedResponse).to.be.undefined;
|
153
|
+
}, 500)
|
153
154
|
done();
|
154
155
|
})
|
155
156
|
.catch(done);
|