<commit_before>'use strict';

var should = require('chai').should(); // eslint-disable-line

describe('swig', function() {
  var r = require('../../../lib/plugins/renderer/swig');

  it('normal', function() {
    var body = [
      'Hello {{ name }}!'
    ].join('\n');

    r({text: body}, {
      name: 'world'
    }).should.eql('Hello world!');
  });

  it('override "for" tag', function() {
    var body = [
      '{% for x in arr %}',
      '{{ x }}',
      '{% endfor %}'
    ].join('');

    var data = {
      arr: {
        toArray: function() {
          return [1, 2, 3];
        }
      }
    };

    r({text: body}, data).should.eql('123');
  });
});<commit_msg>Add test for Swig template compile<commit_after>'use strict';

var should = require('chai').should(); // eslint-disable-line

describe('swig', function() {
  var r = require('../../../lib/plugins/renderer/swig');

  it('normal', function() {
    var body = [
      'Hello {{ name }}!'
    ].join('\n');

    r({text: body}, {
      name: 'world'
    }).should.eql('Hello world!');
  });

  it('override "for" tag', function() {
    var body = [
      '{% for x in arr %}',
      '{{ x }}',
      '{% endfor %}'
    ].join('');

    var data = {
      arr: {
        toArray: function() {
          return [1, 2, 3];
        }
      }
    };

    r({text: body}, data).should.eql('123');
  });

  it('compile', function() {
    var body = [
      'Hello {{ name }}!'
    ].join('\n');

    var render = r.compile({
      text: body
    });

    render({
      name: 'world'
    }).should.eql('Hello world!');
  });
});
{'fraction_non_alphanumeric': 0.23743718592964824, 'fraction_numerical': 0.007537688442211055, 'mean_word_length': 2.011342155009452, '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': '5977716', 'n_tokens_mistral': 561, 'n_tokens_neox': 542, 'n_words': 120}