Skip to content

Commit ab06a20

Browse files
committed
test: add a test case for cacheKeyFn not being called
1 parent 965c884 commit ab06a20

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/__tests__/dataloader.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,20 @@ describe('Accepts options', () => {
750750
expect(cacheMap.get('X')).toBe(promiseX);
751751
});
752752

753+
it('Does not call cacheKeyFn when cache is disabled', async () => {
754+
const cacheKeyFnCalls = [];
755+
const [identityLoader] = idLoader<string>({
756+
cache: false,
757+
cacheKeyFn: key => {
758+
cacheKeyFnCalls.push(key);
759+
return key;
760+
},
761+
});
762+
763+
await identityLoader.load('A');
764+
expect(cacheKeyFnCalls).toEqual([]);
765+
});
766+
753767
it('Complex cache behavior via clearAll()', async () => {
754768
// This loader clears its cache as soon as a batch function is dispatched.
755769
const loadCalls = [];

0 commit comments

Comments
 (0)