From 7d753188a7c06af5fa9fe8fb120bdb4d180cf659 Mon Sep 17 00:00:00 2001 From: Josh Brandoff Date: Fri, 12 Jun 2015 22:28:58 -0400 Subject: [PATCH] Added relevant unit test. --- context_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/context_test.go b/context_test.go index f6083070..c61d8807 100644 --- a/context_test.go +++ b/context_test.go @@ -219,6 +219,17 @@ func TestContextRenderJSON(t *testing.T) { assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/json; charset=utf-8") } +// Tests that the response is serialized as JSON +// and Content-Type is set to application/vnd.api+json +func TestContextRenderJSON(t *testing.T) { + c, w, _ := createTestContext() + c.JSONAPI(201, H{"foo": "bar"}) + + assert.Equal(t, w.Code, 201) + assert.Equal(t, w.Body.String(), "{\"foo\":\"bar\"}\n") + assert.Equal(t, w.HeaderMap.Get("Content-Type"), "application/vnd.api+json") +} + // Tests that the response is serialized as JSON // and Content-Type is set to application/json func TestContextRenderIndentedJSON(t *testing.T) {