<commit_before>
'use strict';

const context = require('../helpers/context');
const assert = require('assert');

describe('ctx.type=', function(){
  describe('with a mime', function(){
    it('should set the Content-Type', function(){
      const ctx = context();
      ctx.type = 'text/plain';
      ctx.type.should.equal('text/plain');
      ctx.response.header['content-type'].should.equal('text/plain; charset=utf-8');
    });
  });

  describe('with an extension', function(){
    it('should lookup the mime', function(){
      const ctx = context();
      ctx.type = 'json';
      ctx.type.should.equal('application/json');
      ctx.response.header['content-type'].should.equal('application/json; charset=utf-8');
    });
  });

  describe('without a charset', function(){
    it('should default the charset', function(){
      const ctx = context();
      ctx.type = 'text/html';
      ctx.type.should.equal('text/html');
      ctx.response.header['content-type'].should.equal('text/html; charset=utf-8');
    });
  });

  describe('with a charset', function(){
    it('should not default the charset', function(){
      const ctx = context();
      ctx.type = 'text/html; charset=foo';
      ctx.type.should.equal('text/html');
      ctx.response.header['content-type'].should.equal('text/html; charset=foo');
    });
  });

  describe('with an unknown extension', function(){
    it('should not set a content-type', function(){
      const ctx = context();
      ctx.type = 'asdf';
      assert(!ctx.type);
      assert(!ctx.response.header['content-type']);
    });
  });
});

describe('ctx.type', function(){
  describe('with no Content-Type', function(){
    it('should return ""', function(){
      const ctx = context();
      // TODO: ctx is lame
      assert('' === ctx.type);
    });
  });

  describe('with a Content-Type', function(){
    it('should return the mime', function(){
      const ctx = context();
      ctx.type = 'json';
      ctx.type.should.equal('application/json');
    });
  });
});<commit_msg>Remove TODO from the response type test<commit_after>
'use strict';

const context = require('../helpers/context');
const assert = require('assert');

describe('ctx.type=', function(){
  describe('with a mime', function(){
    it('should set the Content-Type', function(){
      const ctx = context();
      ctx.type = 'text/plain';
      ctx.type.should.equal('text/plain');
      ctx.response.header['content-type'].should.equal('text/plain; charset=utf-8');
    });
  });

  describe('with an extension', function(){
    it('should lookup the mime', function(){
      const ctx = context();
      ctx.type = 'json';
      ctx.type.should.equal('application/json');
      ctx.response.header['content-type'].should.equal('application/json; charset=utf-8');
    });
  });

  describe('without a charset', function(){
    it('should default the charset', function(){
      const ctx = context();
      ctx.type = 'text/html';
      ctx.type.should.equal('text/html');
      ctx.response.header['content-type'].should.equal('text/html; charset=utf-8');
    });
  });

  describe('with a charset', function(){
    it('should not default the charset', function(){
      const ctx = context();
      ctx.type = 'text/html; charset=foo';
      ctx.type.should.equal('text/html');
      ctx.response.header['content-type'].should.equal('text/html; charset=foo');
    });
  });

  describe('with an unknown extension', function(){
    it('should not set a content-type', function(){
      const ctx = context();
      ctx.type = 'asdf';
      assert(!ctx.type);
      assert(!ctx.response.header['content-type']);
    });
  });
});

describe('ctx.type', function(){
  describe('with no Content-Type', function(){
    it('should return ""', function(){
      const ctx = context();
      assert(!ctx.type);
    });
  });

  describe('with a Content-Type', function(){
    it('should return the mime', function(){
      const ctx = context();
      ctx.type = 'json';
      ctx.type.should.equal('application/json');
    });
  });
});
{'fraction_non_alphanumeric': 0.19447867882671926, 'fraction_numerical': 0.0014789253142716292, 'mean_word_length': 3.2095435684647304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4081956', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1170, 'n_words': 265}