Skip to content

Commit

Permalink
Support for React Native
Browse files Browse the repository at this point in the history
Implementation for the fallback inspect function so that it produces equivalent output to the original inspect behavior.
  • Loading branch information
colincasey committed Dec 2, 2021
2 parents 59a1b3d + 250380a commit cca932a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/memstore.js
Expand Up @@ -186,7 +186,9 @@ class MemoryCookieStore extends Store {
"removeAllCookies",
"getAllCookies"
].forEach(name => {
MemoryCookieStore[name] = fromCallback(MemoryCookieStore.prototype[name]);
MemoryCookieStore.prototype[name] = fromCallback(
MemoryCookieStore.prototype[name]
);
});

exports.MemoryCookieStore = MemoryCookieStore;
Expand Down
22 changes: 22 additions & 0 deletions test/regression_test.js
Expand Up @@ -36,6 +36,7 @@ const async = require("async");
const tough = require("../lib/cookie");
const Cookie = tough.Cookie;
const CookieJar = tough.CookieJar;
const MemoryCookieStore = tough.MemoryCookieStore;

const atNow = Date.now();

Expand Down Expand Up @@ -245,4 +246,25 @@ vows
}
}
)
.addBatch({
MemoryCookieStore: {
topic: new MemoryCookieStore(),
"has no static methods": function() {
assert.deepEqual(Object.keys(MemoryCookieStore), []);
},
"has instance methods that return promises": function(store) {
assert.instanceOf(store.findCookie("example.com", "/", "key"), Promise);
assert.instanceOf(store.findCookies("example.com", "/"), Promise);
assert.instanceOf(store.putCookie({}), Promise);
assert.instanceOf(store.updateCookie({}, {}), Promise);
assert.instanceOf(
store.removeCookie("example.com", "/", "key"),
Promise
);
assert.instanceOf(store.removeCookies("example.com", "/"), Promise);
assert.instanceOf(store.removeAllCookies(), Promise);
assert.instanceOf(store.getAllCookies(), Promise);
}
}
})
.export(module);

0 comments on commit cca932a

Please sign in to comment.