Skip to content

Commit b30445f

Browse files
committed
fix test types
1 parent e1b8592 commit b30445f

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

tests/unit/OnyxSnapshotCacheTest.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {OnyxSnapshotCache} from '../../lib/OnyxSnapshotCache';
22
import OnyxUtils from '../../lib/OnyxUtils';
3-
import type {UseOnyxOptions} from '../../lib/useOnyx';
3+
import type {UseOnyxOptions, UseOnyxResult} from '../../lib/useOnyx';
44

55
// Mock OnyxUtils for testing
66
jest.mock('../../lib/OnyxUtils', () => ({
@@ -17,10 +17,7 @@ type TestData = {
1717
name?: string;
1818
};
1919

20-
type TestResult = {
21-
data: string;
22-
status?: string;
23-
};
20+
type TestResult = UseOnyxResult<{data: string}>;
2421

2522
type TestSelector = (data: unknown) => string;
2623

@@ -67,7 +64,7 @@ describe('OnyxSnapshotCache', () => {
6764
it('should store and retrieve cached results', () => {
6865
const key = 'testKey';
6966
const cacheKey = 'testCacheKey';
70-
const result: TestResult = {data: 'test', status: 'loaded'};
67+
const result: TestResult = [{data: 'test'}, {status: 'loaded'}];
7168

7269
cache.setCachedResult<TestResult>(key, cacheKey, result);
7370
const retrieved = cache.getCachedResult<TestResult>(key, cacheKey);
@@ -81,8 +78,8 @@ describe('OnyxSnapshotCache', () => {
8178
});
8279

8380
it('should clear all caches', () => {
84-
const result1: TestResult = {data: 'test1'};
85-
const result2: TestResult = {data: 'test2'};
81+
const result1: TestResult = [{data: 'test1'}, {status: 'loaded'}];
82+
const result2: TestResult = [{data: 'test2'}, {status: 'loaded'}];
8683

8784
cache.setCachedResult<TestResult>('key1', 'cacheKey1', result1);
8885
cache.setCachedResult<TestResult>('key2', 'cacheKey2', result2);
@@ -152,12 +149,12 @@ describe('OnyxSnapshotCache', () => {
152149
describe('cache invalidation', () => {
153150
beforeEach(() => {
154151
// Set up cache with multiple entries
155-
cache.setCachedResult<TestResult>('reports_', 'cache1', {data: 'collection'});
156-
cache.setCachedResult<TestResult>('reports_123', 'cache2', {data: 'member1'});
157-
cache.setCachedResult<TestResult>('reports_456', 'cache3', {data: 'member2'});
158-
cache.setCachedResult<TestResult>('users_', 'cache4', {data: 'users collection'});
159-
cache.setCachedResult<TestResult>('users_789', 'cache5', {data: 'user member'});
160-
cache.setCachedResult<TestResult>('nonCollectionKey', 'cache6', {data: 'regular key'});
152+
cache.setCachedResult<TestResult>('reports_', 'cache1', [{data: 'collection'}, {status: 'loaded'}]);
153+
cache.setCachedResult<TestResult>('reports_123', 'cache2', [{data: 'member1'}, {status: 'loaded'}]);
154+
cache.setCachedResult<TestResult>('reports_456', 'cache3', [{data: 'member2'}, {status: 'loaded'}]);
155+
cache.setCachedResult<TestResult>('users_', 'cache4', [{data: 'users collection'}, {status: 'loaded'}]);
156+
cache.setCachedResult<TestResult>('users_789', 'cache5', [{data: 'user member'}, {status: 'loaded'}]);
157+
cache.setCachedResult<TestResult>('nonCollectionKey', 'cache6', [{data: 'regular key'}, {status: 'loaded'}]);
161158
});
162159

163160
it('should invalidate non-collection keys without affecting others', () => {

0 commit comments

Comments
 (0)