File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
play-json/shared/src/test/scala/play/api/libs/json Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
3+ */
4+
5+ package play .api .libs .json
6+
7+ import play .api .libs .json .Json ._
8+
9+ import org .scalatest .matchers .must .Matchers
10+ import org .scalatest .wordspec .AnyWordSpec
11+
12+ class JsLookupSpec extends AnyWordSpec with Matchers {
13+ " JsLookupResult" should {
14+ val obj = Json .obj(
15+ " field" -> 123
16+ )
17+ val result = obj \ " missingField"
18+
19+ " return JsUndefined when a key is missing" in {
20+ result mustBe a[JsUndefined ]
21+ }
22+
23+ " return None when calling asOpt on JsUndefined" in {
24+ result.asOpt[Int ] mustEqual None
25+ }
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments