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 094a052
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export abstract class EventRepository {
/**
* This property indicates 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 094a052

Please sign in to comment.