<commit_before>'use strict';

var expect              = require('chai').expect;
var HistorySupportAddon = require('../../../../../lib/tasks/server/middleware/history-support');

describe('HistorySupportAddon', function () {
  describe('.serverMiddleware', function () {
    it('add middleware when locationType is auto', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            locationType: 'auto'
          };
        }
      });

      expect(addon.shouldAddMiddleware()).to.true;
    });

    it('add middleware when locationType is history', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            locationType: 'history'
          };
        }
      });

      expect(addon.shouldAddMiddleware()).to.true;
    });

    it('add middleware when historySupportMiddleware is true', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            historySupportMiddleware: true
          };
        }
      });

      expect(addon.shouldAddMiddleware()).to.true;
    });

    it('do not add middleware when historySupportMiddleware is false and locationType is history', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            locationType: 'history',<commit_msg>Adding a test to cover historySupportMiddleware with unknown location type<commit_after>'use strict';

var expect              = require('chai').expect;
var HistorySupportAddon = require('../../../../../lib/tasks/server/middleware/history-support');

describe('HistorySupportAddon', function () {
  describe('.serverMiddleware', function () {
    it('add middleware when locationType is auto', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            locationType: 'auto'
          };
        }
      });

      expect(addon.shouldAddMiddleware()).to.true;
    });

    it('add middleware when locationType is history', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            locationType: 'history'
          };
        }
      });

      expect(addon.shouldAddMiddleware()).to.true;
    });

    it('add middleware when locationType is an unknown type', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            locationType: 'foo-bar',
            historySupportMiddleware: true
          };
        }
      });

      expect(addon.shouldAddMiddleware()).to.true;
    });

    it('add middleware when historySupportMiddleware is true', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            historySupportMiddleware: true
          };
        }
      });

      expect(addon.shouldAddMiddleware()).to.true;
    });

    it('do not add middleware when historySupportMiddleware is false and locationType is history', function() {
      var addon = new HistorySupportAddon({
        config: function() {
          return {
            locationType: 'history',
{'fraction_non_alphanumeric': 0.121875, 'fraction_numerical': 0.0, 'mean_word_length': 2.204204204204204, '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': '7247366', 'n_tokens_mistral': 810, 'n_tokens_neox': 809, 'n_words': 199}