Permalink
Browse files

Last few tests for JSONEncoder

  • Loading branch information...
1 parent d6f81e6 commit 61e327157d79122eca88654a95fe5a74ceae2b53 @hlship committed Jul 16, 2011
Showing with 17 additions and 1 deletion.
  1. +17 −1 tapx-json/src/test/groovy/json/tests/JSONEncoderTests.groovy
@@ -4,11 +4,11 @@ import com.howardlewisship.tapx.json.JSONEncoder
import com.howardlewisship.tapx.json.JSONModule
import org.apache.tapestry5.ioc.Registry
import org.apache.tapestry5.ioc.RegistryBuilder
+import org.apache.tapestry5.json.JSONArray
import org.apache.tapestry5.json.JSONObject
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
-import org.apache.tapestry5.json.JSONArray
/**
* Tests various implementations of {@link com.howardlewisship.tapx.json.JSONEncoder}.
@@ -61,4 +61,20 @@ class JSONEncoderTests extends Specification {
output == expected
}
+ def "encoding of nested maps and lists"() {
+ when:
+
+ def input = [top: [level: 'nested'], anArray: [1, 2, 3, [level: 'deep']]]
+ def output = encoder.encodeAsJSON(input)
+ def expected = new JSONObject("""
+ { "top" : { "level" : "nested" },
+ "anArray" : [1, 2, 3, { "level" : "deep" }]}
+ """)
+
+ then:
+
+ output == expected
+ }
+
+
}

0 comments on commit 61e3271

Please sign in to comment.