Skip to content

Commit

Permalink
Test written for Pin/Unpin Api
Browse files Browse the repository at this point in the history
  • Loading branch information
Porush Tyagi committed Oct 7, 2022
1 parent 957b200 commit 3ad9f74
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,67 @@ class NotyRemoteNoteRepositoryTest : BehaviorSpec({
}
}
}

When("Note is Pinned") {
And("Inputs Are Valid") {
val response = repository.pinNote(noteId = "1111", isPinned = true)

Then("Note Pinning should be requested") {
coVerify { service.updateNotePin(noteId = "1111", NoteUpdatePinRequest(isPinned = true)) }
}

Then("Valid response should be returned") {
val id = (response as Either.Success).data
id shouldBe "1111"
}
}

And("Inputs are invalid") {
val response = repository.pinNote(noteId = "2222", isPinned = true)

Then("Note pinning should be requested") {
coVerify {
service.updateNotePin(noteId = "2222", NoteUpdatePinRequest(isPinned = true))
}
}

Then("Error response should be returned") {
val message = (response as Either.Error).message
message shouldBe "Failed to perform operation"
}
}
}

When("Note is UnPinned") {
And("Inputs Are Valid") {
val response = repository.pinNote(noteId = "1111", isPinned = false)

Then("Note Pinning should be requested") {
coVerify { service.updateNotePin(noteId = "1111", NoteUpdatePinRequest(isPinned = false)) }
}

Then("Valid response should be returned") {
val id = (response as Either.Success).data
id shouldBe "1111"
}
}

And("Inputs are invalid") {
val response = repository.pinNote(noteId = "2222", isPinned = false)

Then("Note pinning should be requested") {
coVerify {
service.updateNotePin(noteId = "2222", NoteUpdatePinRequest(isPinned = false))
}
}

Then("Error response should be returned") {
val message = (response as Either.Error).message
message shouldBe "Failed to perform operation"
}
}
}

}
})

Expand Down

0 comments on commit 3ad9f74

Please sign in to comment.