test: complete todo

Signed-off-by: yamashush <38120991+yamashush@users.noreply.github.com>
This commit is contained in:
yamashush 2024-01-19 12:21:27 +09:00 committed by Philip Molares
parent 662de1e9f8
commit 1c22a425bd

View file

@ -393,15 +393,18 @@ describe('HistoryService', () => {
updatedAt: historyEntryImport.lastVisitedAt,
};
const createQueryBuilder = mockSelectQueryBuilderInRepo(noteRepo, note);
mockSelectQueryBuilderInRepo(noteRepo, note);
const createQueryBuilderForEntityManager = {
where: () => createQueryBuilderForEntityManager,
getMany: () => [historyEntry],
};
const mockedManager = Mock.of<EntityManager>({
find: jest.fn().mockResolvedValueOnce([historyEntry]),
createQueryBuilder: () => createQueryBuilder,
remove: jest.fn().mockImplementationOnce(async (_: HistoryEntry) => {
// TODO: reimplement checks below
//expect(await (await entry.note).aliases).toHaveLength(1);
//expect((await (await entry.note).aliases)[0].name).toEqual(alias);
//expect(entry.pinStatus).toEqual(false);
createQueryBuilder: jest.fn().mockImplementation(() => createQueryBuilderForEntityManager),
remove: jest.fn().mockImplementationOnce(async (entry: HistoryEntry) => {
expect(await (await entry.note).aliases).toHaveLength(1);
expect((await (await entry.note).aliases)[0].name).toEqual(alias);
expect(entry.pinStatus).toEqual(false);
}),
save: jest.fn().mockImplementationOnce(async (entry: HistoryEntry) => {
expect((await entry.note).aliases).toEqual(