@@ -72,16 +72,35 @@ describe('Utility functions', function () {
7272 } )
7373
7474 describe ( 'getContentType()' , ( ) => {
75- it ( 'should default to text/plain' , ( ) => {
76- assert . equal ( utils . getContentType ( { } ) , 'text/plain' )
77- } )
75+ describe ( 'for Express headers' , ( ) => {
76+ it ( 'should default to text/plain' , ( ) => {
77+ assert . equal ( utils . getContentType ( { } ) , 'text/plain' )
78+ } )
79+
80+ it ( 'should get a basic content type' , ( ) => {
81+ assert . equal ( utils . getContentType ( { 'content-type' : 'text/html' } ) , 'text/html' )
82+ } )
7883
79- it ( 'should get a basic content type' , ( ) => {
80- assert . equal ( utils . getContentType ( { 'content-type' : 'text/html' } ) , 'text/html' )
84+ it ( 'should get a content type without its charset' , ( ) => {
85+ assert . equal ( utils . getContentType ( { 'content-type' : 'text/html; charset=us-ascii' } ) , 'text/html' )
86+ } )
8187 } )
8288
83- it ( 'should get a content type without its charset' , ( ) => {
84- assert . equal ( utils . getContentType ( { 'content-type' : 'text/html; charset=us-ascii' } ) , 'text/html' )
89+ describe ( 'for Fetch API headers' , ( ) => {
90+ it ( 'should default to text/plain' , ( ) => {
91+ // eslint-disable-next-line no-undef
92+ assert . equal ( utils . getContentType ( new Headers ( { } ) ) , 'text/plain' )
93+ } )
94+
95+ it ( 'should get a basic content type' , ( ) => {
96+ // eslint-disable-next-line no-undef
97+ assert . equal ( utils . getContentType ( new Headers ( { 'content-type' : 'text/html' } ) ) , 'text/html' )
98+ } )
99+
100+ it ( 'should get a content type without its charset' , ( ) => {
101+ // eslint-disable-next-line no-undef
102+ assert . equal ( utils . getContentType ( new Headers ( { 'content-type' : 'text/html; charset=us-ascii' } ) ) , 'text/html' )
103+ } )
85104 } )
86105 } )
87106} )
0 commit comments