From 779defa5d09c906ad4578c6b6330e0c7f54d424f Mon Sep 17 00:00:00 2001 From: ChuyB Date: Thu, 10 Oct 2024 12:07:31 -0400 Subject: [PATCH 1/2] =?UTF-8?q?A=C3=B1ade=20pruebas=20para=20la=20b=C3=BAs?= =?UTF-8?q?queda=20de=20bookmarks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/search.js | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/test/search.js b/test/search.js index f0e285cb9d..dc18a6012b 100644 --- a/test/search.js +++ b/test/search.js @@ -11,6 +11,7 @@ const user = require('../src/user'); const search = require('../src/search'); const privileges = require('../src/privileges'); const request = require('../src/request'); +const posts = require('../src/posts'); describe('Search', () => { let phoebeUid; @@ -136,6 +137,48 @@ describe('Search', () => { assert.strictEqual(data.length, 5); }); + it('should search in bookmarks', async () => { + posts.bookmark(post1Data.pid, gingerUid); + let result = await search.search({ + searchIn: 'bookmarks', + uid: gingerUid, + categories: ['all'], + }) + assert.strictEqual(result.matchCount, 1); + assert.strictEqual(result.posts[0].pid, post1Data.pid); + }); + + it('should not find any bookmark', async () => { + const result = await search.search({ + searchIn: 'bookmarks', + uid: phoebeUid, + categories: ['all'], + }); + assert.strictEqual(result.matchCount, 0); + }); + + it('should search bookmark by query', async () => { + posts.bookmark(post1Data.pid, gingerUid); + let result = await search.search({ + query: 'nodebb', + searchIn: 'bookmarks', + uid: gingerUid, + categories: ['all'], + matchWords: "any", + }); + assert.strictEqual(result.matchCount, 1); + assert.strictEqual(result.posts[0].pid, post1Data.pid); + + result = await search.search({ + query: 'xxxx', + searchIn: 'bookmarks', + uid: gingerUid, + categories: ['all'], + matchWords: "any", + }); + assert.strictEqual(result.matchCount, 0); + }) + it('should fail if searchIn is wrong', (done) => { search.search({ query: 'plug', @@ -224,4 +267,4 @@ describe('Search', () => { assert.strictEqual(response.statusCode, 200); await privileges.global.rescind(['groups:search:content'], 'guests'); }); -}); +}); \ No newline at end of file From 04d2f9bd6a9464a97e97dda7f6a35f1fbdb25dae Mon Sep 17 00:00:00 2001 From: ChuyB Date: Fri, 11 Oct 2024 18:38:36 -0400 Subject: [PATCH 2/2] Corrige errores del linter --- test/search.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/search.js b/test/search.js index dc18a6012b..7a6db73d1d 100644 --- a/test/search.js +++ b/test/search.js @@ -139,11 +139,11 @@ describe('Search', () => { it('should search in bookmarks', async () => { posts.bookmark(post1Data.pid, gingerUid); - let result = await search.search({ + const result = await search.search({ searchIn: 'bookmarks', uid: gingerUid, categories: ['all'], - }) + }); assert.strictEqual(result.matchCount, 1); assert.strictEqual(result.posts[0].pid, post1Data.pid); }); @@ -164,7 +164,7 @@ describe('Search', () => { searchIn: 'bookmarks', uid: gingerUid, categories: ['all'], - matchWords: "any", + matchWords: 'any', }); assert.strictEqual(result.matchCount, 1); assert.strictEqual(result.posts[0].pid, post1Data.pid); @@ -174,10 +174,10 @@ describe('Search', () => { searchIn: 'bookmarks', uid: gingerUid, categories: ['all'], - matchWords: "any", + matchWords: 'any', }); assert.strictEqual(result.matchCount, 0); - }) + }); it('should fail if searchIn is wrong', (done) => { search.search({ @@ -267,4 +267,4 @@ describe('Search', () => { assert.strictEqual(response.statusCode, 200); await privileges.global.rescind(['groups:search:content'], 'guests'); }); -}); \ No newline at end of file +});