From 7c8d6339c869af88196566fd12508922798dd540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rex=20Lee=28=E6=9D=8E=E4=BF=8A=29?= Date: Wed, 16 May 2018 17:12:55 +0800 Subject: [PATCH] add test for AsciiJSON in context --- context_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/context_test.go b/context_test.go index 12e02fa0..feded21c 100644 --- a/context_test.go +++ b/context_test.go @@ -686,6 +686,17 @@ func TestContextRenderNoContentSecureJSON(t *testing.T) { assert.Equal(t, "application/json; charset=utf-8", w.HeaderMap.Get("Content-Type")) } +func TestContextRenderNoContentAsciiJSON(t *testing.T) { + w := httptest.NewRecorder() + c, _ := CreateTestContext(w) + + c.AsciiJSON(204, []string{"lang", "Go语言"}) + + assert.Equal(t, 204, w.Code) + assert.Empty(t, w.Body.String()) + assert.Equal(t, "application/json", w.HeaderMap.Get("Content-Type")) +} + // Tests that the response executes the templates // and responds with Content-Type set to text/html func TestContextRenderHTML(t *testing.T) {