fix: Minor fixes in backlinks service (#1240)

This commit is contained in:
Tom Moor
2020-04-24 05:29:48 -07:00
committed by GitHub
parent 9f8e7be755
commit c41e6e0423
2 changed files with 36 additions and 7 deletions

View File

@@ -10,6 +10,28 @@ beforeEach(flushdb);
beforeEach(jest.resetAllMocks);
describe('documents.update', () => {
test('should not fail on a document with no previous revisions', async () => {
const otherDocument = await buildDocument();
const document = await buildDocument({
text: `[this is a link](${otherDocument.url})`,
});
await Backlinks.on({
name: 'documents.update',
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
actorId: document.createdById,
data: { autosave: false },
});
const backlinks = await Backlink.findAll({
where: { reverseDocumentId: document.id },
});
expect(backlinks.length).toBe(1);
});
test('should create new backlink records', async () => {
const otherDocument = await buildDocument();
const document = await buildDocument();