From abf2f820cfadffce1b3e6b205962cafb455631bc Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Thu, 14 Dec 2023 17:14:15 +0700 Subject: [PATCH] Increased snippets core code coverage to 100% --- .../core/snippets/snippets.service.test.ts | 20 ++++++++++++++++--- .../src/core/snippets/snippets.service.ts | 4 ++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ghost/ghost/src/core/snippets/snippets.service.test.ts b/ghost/ghost/src/core/snippets/snippets.service.test.ts index fa4bbb246f..0c074a8b87 100644 --- a/ghost/ghost/src/core/snippets/snippets.service.test.ts +++ b/ghost/ghost/src/core/snippets/snippets.service.test.ts @@ -18,7 +18,9 @@ describe('SnippetService', () => { assert(allSnippets[0].name === snippet.name); const updated = await service.update(snippet.id, { - name: 'Updated Name' + name: 'Updated Name', + lexical: '{}', + mobiledoc: '{}' }); assert(updated); @@ -30,10 +32,22 @@ describe('SnippetService', () => { assert(pageOfSnippets.data[0].name === updated.name); - await service.delete(snippet.id); + const deleted = await service.delete(snippet.id); + + assert(deleted); + + const cannotDelete = await service.delete(deleted.id); + + assert(!cannotDelete); + + const cannotUpdate = await service.update(deleted.id, { + name: 'Updated Again' + }); + + assert(!cannotUpdate); const notFound = await service.getOne(snippet.id); - assert(notFound === null); + assert(!notFound); }); }); diff --git a/ghost/ghost/src/core/snippets/snippets.service.ts b/ghost/ghost/src/core/snippets/snippets.service.ts index cfc8f77004..89c4edcc08 100644 --- a/ghost/ghost/src/core/snippets/snippets.service.ts +++ b/ghost/ghost/src/core/snippets/snippets.service.ts @@ -66,8 +66,8 @@ export class SnippetsService { async getPage(options: {filter?: string, page: number, limit: number}) { const filter = options.filter; - const page = options.page || 1; - const limit = options.limit || 15; + const page = options.page; + const limit = options.limit; const data = await this.repository.getSome({ count: limit,