Skip to content

Commit

Permalink
refactor: covert isSearchSupported from property to method in eventRe…
Browse files Browse the repository at this point in the history
…pository
  • Loading branch information
CodyTseng committed Mar 23, 2024
1 parent 3403dc7 commit ec063a7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/common/src/interfaces/event-repository.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export interface EventRepositoryUpsertResult {
*/
export abstract class EventRepository {
/**
* This property indicates whether the search feature is supported.
* Whether the search feature is supported.
*/
readonly isSearchSupported: boolean = false;
abstract isSearchSupported(): boolean;

/**
* This method is called when a new event should be stored. You should handle
Expand Down
2 changes: 1 addition & 1 deletion packages/core/__test__/services/event.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('eventService', () => {

beforeEach(() => {
eventRepository = {
isSearchSupported: false,
isSearchSupported: jest.fn().mockReturnValue(false),
upsert: jest.fn(),
find: jest.fn(),
findOne: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class EventService {
const callback = async (): Promise<Event[]> => {
if (
filter.search !== undefined &&
!this.eventRepository.isSearchSupported
!this.eventRepository.isSearchSupported()
) {
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ describe('EventRepositorySqlite', () => {
eventRepository.close();
});

describe('isSearchSupported', () => {
it('should return false', () => {
expect(eventRepository.isSearchSupported()).toBe(false);
});
});

describe('upsert', () => {
it('should insert a new event', async () => {
const eventA = createEvent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export class EventRepositorySqlite extends EventRepository {
this.migrate();
}

isSearchSupported(): boolean {
return false;
}

close(): void {
this.db.close();
}
Expand Down

0 comments on commit ec063a7

Please sign in to comment.