Spec of Section in Parsley
import org.scalatest.{FlatSpec, Matchers} | |
import play.api.test.Helpers._ | |
import play.api.test._ | |
class ApiSpec extends FlatSpec with Matchers { | |
"GET /api/get/:username" should | |
"return json result" in new WithApplication { | |
val home = route(FakeRequest(GET, "/api/get/nb")).get | |
status(home) should be(OK) | |
} | |
} |
package services.slick | |
import models.Section | |
import org.scalatest.{FlatSpec, Matchers} | |
import play.api.test.WithApplication | |
import services.TestJector | |
/** | |
* Created by nuboat | |
*/ | |
class SlickSectionServiceSpec extends FlatSpec with Matchers { | |
val id = System.currentTimeMillis() | |
"SlickSectionService.saveSection with null sectionId" should | |
"return with new sectionId" in new WithApplication { | |
val service = TestJector.instance[SlickSectionService] | |
val section = Section(null, "nb", 0, """{"title":"I am Peerapat"}""", 1) | |
val result = service.saveSection(section) | |
result.isEmpty should be(false) | |
result.get.sectionId should not be("-1") | |
} | |
"SlickSectionService.saveSection with sectionId exist sectionId" should | |
"No Error" in new WithApplication { | |
val service = TestJector.instance[SlickSectionService] | |
val section = Section("621247bd-19ab-4645-aed5-c2d4869bd484", "nb", 0, """{"title":"With"}""", 1) | |
val result = service.saveSection(section) | |
result.isEmpty should be(false) | |
} | |
"SlickSectionService.findByUser with username = 'nb'" should | |
"No Error" in new WithApplication { | |
val service = TestJector.instance[SlickSectionService] | |
val result = service.findByUser("nb") | |
result.isEmpty should be(false) | |
} | |
"SlickSectionService.updateValue with sectionId = '0c09d054-02ff-42b2-ac2d-b68b48ac806e'" should | |
"No Error" in new WithApplication { | |
val service = TestJector.instance[SlickSectionService] | |
val result = service.updateValue("norbor", "0c09d054-02ff-42b2-ac2d-b68b48ac806e", 1, "", "") | |
result.isDefined should be(true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment