From fc8ab1741c396fb11cbb8320c624a549bc21d05b Mon Sep 17 00:00:00 2001 From: NerinaHctz Date: Mon, 5 Aug 2024 08:54:12 +0200 Subject: [PATCH] modify deletePost.spec, getAllPosts.spec, toggleLikePost.spec and updatePostCaption.spec #68 --- .../ponies/cor/logic/deletePost.spec.js | 4 ++-- .../ponies/cor/logic/getAllPosts.spec.js | 2 +- .../ponies/cor/logic/toggleLikePost.spec.js | 13 ------------- .../ponies/cor/logic/updatePostCaption.spec.js | 2 +- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/staff/nerina-castillo/ponies/cor/logic/deletePost.spec.js b/staff/nerina-castillo/ponies/cor/logic/deletePost.spec.js index 823bcb98d..53d65edf0 100644 --- a/staff/nerina-castillo/ponies/cor/logic/deletePost.spec.js +++ b/staff/nerina-castillo/ponies/cor/logic/deletePost.spec.js @@ -46,7 +46,7 @@ describe('deletePost', () => { it('fails on existing user but non-existing post', () => { User.create({ name: 'gon', surname: 'zalo', email: 'gon@zalo.com', username: 'gonzalo', password: 'gonzalo123' }) - .then(() => deletePost(user.id, new ObjectId().toString())) + .then(user => deletePost(user.id, new ObjectId().toString())) .catch(error => _error = error) .finally(() => { expect(_error).to.be.instanceOf(NotFoundError) @@ -84,7 +84,7 @@ describe('deletePost', () => { let error try { - deletePost('gonzalo', 123) + deletePost(new ObjectId().toString(), 123) } catch (_error) { error = _error } finally { diff --git a/staff/nerina-castillo/ponies/cor/logic/getAllPosts.spec.js b/staff/nerina-castillo/ponies/cor/logic/getAllPosts.spec.js index 429df0f57..303aa60d8 100644 --- a/staff/nerina-castillo/ponies/cor/logic/getAllPosts.spec.js +++ b/staff/nerina-castillo/ponies/cor/logic/getAllPosts.spec.js @@ -22,7 +22,7 @@ describe('getAllPosts', () => { .then(user => Post.create({ author: new ObjectId().toString(), image: 'https://media.giphy.com/media/ji6zzUZwNIuLS/giphy.gif?cid=790b7611qml3yetzjkqcp26cvoxayvif8j713kmqj2yp06oi&ep=v1_gifs_trending&rid=giphy.gif&ct=g', caption: 'i am fine' }) .then(post1 => { - Post.create({ author: 'gonzalo', image: 'https://media.giphy.com/media/ji6zzUZwNIuLS/giphy.gif?cid=790b7611qml3yetzjkqcp26cvoxayvif8j713kmqj2yp06oi&ep=v1_gifs_trending&rid=giphy.gif&ct=g', caption: 'i am fine' }) + Post.create({ author: new ObjectId().toString(), image: 'https://media.giphy.com/media/ji6zzUZwNIuLS/giphy.gif?cid=790b7611qml3yetzjkqcp26cvoxayvif8j713kmqj2yp06oi&ep=v1_gifs_trending&rid=giphy.gif&ct=g', caption: 'i am fine' }) .then(post2 => { getAllPosts(user.id) diff --git a/staff/nerina-castillo/ponies/cor/logic/toggleLikePost.spec.js b/staff/nerina-castillo/ponies/cor/logic/toggleLikePost.spec.js index 9523f8219..629565d73 100644 --- a/staff/nerina-castillo/ponies/cor/logic/toggleLikePost.spec.js +++ b/staff/nerina-castillo/ponies/cor/logic/toggleLikePost.spec.js @@ -79,19 +79,6 @@ describe('toggleLikePost', () => { } }) - it('fails on non-string userId', () => { - let error - - try { - toggleLikePost(123, new ObjectId().toString()) - } catch (_error) { - error = _error - } finally { - expect(error).to.be.instanceOf(ValidationError) - expect(error.message).to.equal('userId is not a string') - } - }) - it('fails on non-string postId', () => { let error diff --git a/staff/nerina-castillo/ponies/cor/logic/updatePostCaption.spec.js b/staff/nerina-castillo/ponies/cor/logic/updatePostCaption.spec.js index 399dcbe56..7880ba311 100644 --- a/staff/nerina-castillo/ponies/cor/logic/updatePostCaption.spec.js +++ b/staff/nerina-castillo/ponies/cor/logic/updatePostCaption.spec.js @@ -21,7 +21,7 @@ describe('updatePostCaption', () => { User.create({ name: 'gon', surname: 'zalo', email: 'gon@zalo.com', username: 'gonzalo', password: 'gonzalo123' }) .then(user => { Post.create({ author: user.id, image: 'https://media.giphy.com/media/ji6zzUZwNIuLS/giphy.gif?cid=790b7611qml3yetzjkqcp26cvoxayvif8j713kmqj2yp06oi&ep=v1_gifs_trending&rid=giphy.gif&ct=g', caption: 'i am fine' }) - .then(post => updatePostCaption('gonzalo', post.id, 'okay...')) + .then(post => updatePostCaption(user.id, post.id, 'okay...')) Post.findById(post.id).lean() .then(post => {