Skip to content

Commit

Permalink
Last few tests for JSONEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
hlship committed Oct 12, 2011
1 parent ff82c7e commit 27b74e1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tapx-json/src/test/groovy/json/tests/JSONEncoderTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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 27b74e1

Please sign in to comment.