Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions packages/tron-wallet-snap/src/caching/useCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,20 @@ describe('useCache', () => {

describe('when the data is cached', () => {
it('should return the cached result', async () => {
// Init the cache with some data
jest.spyOn(cache, 'get').mockResolvedValue('test');
await withUseCache(
async ({ actualExecutionSpy, cache, cachedTestFunction }) => {
// Init the cache with some data
cache.get.mockResolvedValue('test');
// jest.spyOn(cache, 'get').mockResolvedValue('test');

const result = await cachedTestFunction();
const result = await cachedTestFunction();

expect(result).toBe('test');
expect(cache.get).toHaveBeenCalledTimes(1);
expect(actualExecutionSpy).not.toHaveBeenCalled();
expect(cache.set).not.toHaveBeenCalled();
expect(result).toBe('test');
expect(cache.get).toHaveBeenCalledTimes(1);
expect(actualExecutionSpy).not.toHaveBeenCalled();
expect(cache.set).not.toHaveBeenCalled();
},
);
});
});

Expand Down