All files / testing draft-storage.mock.ts

50% Statements 7/14
0% Branches 0/1
50% Functions 2/4
50% Lines 7/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x 1x   1x                 1x             1x 2x   7x      
import { DraftStorageService } from '../draft-storage/draft-storage.service';
import { DRAFT_USER_ID_PROVIDER } from '../draft-storage/draft-user-id.token';
 
export class MockDraftStorageService {
    save = jest.fn().mockResolvedValue(undefined);
    getByRoute = jest.fn().mockResolvedValue(undefined);
    getAll = jest.fn().mockResolvedValue([]);
    getCount = jest.fn().mockResolvedValue(0);
    deleteByRoute = jest.fn().mockResolvedValue(undefined);
    deleteAll = jest.fn().mockResolvedValue(undefined);
}
 
export function mockDraftStorageProvider() {
    return {
        provide: DraftStorageService,
        useClass: MockDraftStorageService,
    };
}
 
export function mockDraftUserIdProvider(userId = 'test-user') {
    return {
        provide: DRAFT_USER_ID_PROVIDER,
        useValue: () => userId,
    };
}