<commit_before>var rewire = require('rewire');
var engineFactory = rewire('../../services/nunjucks-template-engine');

describe("nunjucksTemplateEngine service", function() {
  var nunjucks, addFilterSpy, addExtensionSpy, engine;

  beforeEach(function() {

    nunjucks = engineFactory.__get__('nunjucks');

    nunjucks.Environment = jasmine.createSpy('Environment');
    nunjucks.Environment.prototype.addFilter = addFilterSpy = jasmine.createSpy('addFilter');
    nunjucks.Environment.prototype.addExtension = addExtensionSpy = jasmine.createSpy('addExtension');

    engine = engineFactory();
  });

  describe("getRenderer()", function() {

    it("should configure nunjucks", function() {

      engine.templateFolders = ['templates'];
      engine.config = { foo: 'bar' };

      var render = engine.getRenderer();
      expect(render).toEqual(jasmine.any(Function));

      expect(nunjucks.Environment).toHaveBeenCalledWith(
        jasmine.any(nunjucks.FileSystemLoader),
        engine.config
      );
    });


    it("should load the given custom filters", function() {

      var dummyFilter = { name: 'test', process: function() {} };<commit_msg>test(nunjucks/templateEngine): templateEngine now relies on templateFinder<commit_after>var rewire = require('rewire');
var engineFactory = rewire('../../services/nunjucks-template-engine');

describe("nunjucksTemplateEngine service", function() {
  var nunjucks, addFilterSpy, addExtensionSpy, engine, mockTemplateFinder;

  beforeEach(function() {

    nunjucks = engineFactory.__get__('nunjucks');

    nunjucks.Environment = jasmine.createSpy('Environment');
    nunjucks.Environment.prototype.addFilter = addFilterSpy = jasmine.createSpy('addFilter');
    nunjucks.Environment.prototype.addExtension = addExtensionSpy = jasmine.createSpy('addExtension');

    mockTemplateFinder = {
      templateFolders: 'templates'
    };
    engine = engineFactory(mockTemplateFinder);
  });

  describe("getRenderer()", function() {

    it("should configure nunjucks", function() {

      engine.templateFolders = ['templates'];
      engine.config = { foo: 'bar' };

      var render = engine.getRenderer();
      expect(render).toEqual(jasmine.any(Function));

      expect(nunjucks.Environment).toHaveBeenCalledWith(
        jasmine.any(nunjucks.FileSystemLoader),
        engine.config
      );
    });


    it("should load the given custom filters", function() {

      var dummyFilter = { name: 'test', process: function() {} };
{'fraction_non_alphanumeric': 0.13654618473895583, 'fraction_numerical': 0.0, 'mean_word_length': 4.233193277310924, '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': '252477', 'n_tokens_mistral': 740, 'n_tokens_neox': 718, 'n_words': 125}