Skip to content

Commit

Permalink
Fix migration loop continue statement
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Mar 15, 2024
1 parent 64192b8 commit 89957ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions sci-log-db/src/__tests__/acceptance/migrate.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,33 @@ describe('Migrate', function (this: Suite) {
await paragraph.execute('Paragraph', 'insertOne', {
id: '123',
ownerGroup: 'paragraphAcceptance',
textcontent: '<p></p>',
});
await paragraph.execute('Paragraph', 'insertOne', {
id: '456',
ownerGroup: 'paragraphAcceptance',
textcontent: '<p>h &hearts;</p>',
});
const sanitizeTextContentStub = sandbox
.stub(util, 'sanitizeTextContent')
.callThrough();
await paragraph.migrateHtmlTexcontent();
expect(sanitizeTextContentStub.args[0][0]).to.be.eql('<p>h &hearts;</p>');
const modified = await paragraph.execute('Paragraph', 'findOne', {
id: '123',
});
expect(modified.htmlTextcontent).to.be.eql('h ♥');
expect(sanitizeTextContentStub.callCount).to.be.eql(2);
expect(sanitizeTextContentStub.args[0][0]).to.be.eql('<p></p>');
expect(
(
await paragraph.execute('Paragraph', 'findOne', {
id: '123',
})
).htmlTextcontent,
).to.be.eql(undefined);
expect(sanitizeTextContentStub.args[1][0]).to.be.eql('<p>h &hearts;</p>');
expect(
(
await paragraph.execute('Paragraph', 'findOne', {
id: '456',
})
).htmlTextcontent,
).to.be.eql('h ♥');
});
});
2 changes: 1 addition & 1 deletion sci-log-db/src/repositories/paragraph.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ParagraphRepository extends SnippetRepositoryMixin<
const baseSnippetRepository = await this.baseSnippetRepository();
for await (const paragraph of paragraphsCursor) {
const sanitised = sanitizeTextContent(paragraph.textcontent);
if (!sanitised) return;
if (!sanitised) continue;
await baseSnippetRepository.updateById(
`${paragraph._id}`,
{htmlTextcontent: sanitised},
Expand Down

0 comments on commit 89957ba

Please sign in to comment.