Skip to content

Commit

Permalink
modify deletePost.spec, getAllPosts.spec, toggleLikePost.spec and upd…
Browse files Browse the repository at this point in the history
…atePostCaption.spec b00tc4mp#68
  • Loading branch information
NerinaHctz committed Aug 5, 2024
1 parent c01f64e commit fc8ab17
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
4 changes: 2 additions & 2 deletions staff/nerina-castillo/ponies/cor/logic/deletePost.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('deletePost', () => {

it('fails on existing user but non-existing post', () => {
User.create({ name: 'gon', surname: 'zalo', email: '[email protected]', 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)
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('deletePost', () => {
let error

try {
deletePost('gonzalo', 123)
deletePost(new ObjectId().toString(), 123)
} catch (_error) {
error = _error
} finally {
Expand Down
2 changes: 1 addition & 1 deletion staff/nerina-castillo/ponies/cor/logic/getAllPosts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
13 changes: 0 additions & 13 deletions staff/nerina-castillo/ponies/cor/logic/toggleLikePost.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('updatePostCaption', () => {
User.create({ name: 'gon', surname: 'zalo', email: '[email protected]', 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 => {
Expand Down

0 comments on commit fc8ab17

Please sign in to comment.