<commit_before>/*global describe, it*/
'use strict';

var fs = require('fs'),
  path = require('path'),
  should = require('should');
require('mocha');

var gutil = require('gulp-util'),
  inject = require('../');

function expectedFile (file) {
  var filepath = path.join('test/expected', file);
  return new gutil.File({
    path: filepath,
    cwd: 'test/',
    base: path.basename(filepath),
    contents: fs.readFileSync(filepath)
  });
}

function fixture (file) {
  var filepath = path.join('test/fixtures', file);
  return new gutil.File({
    path: filepath,
    cwd: 'test/',
    base: path.basename(filepath),
    contents: null
  });
}

describe('gulp-inject', function () {

  it('should inject stylesheets, scripts and html components into desired file', function (done) {

    var sources = [
      fixture('lib.js'),
      fixture('component.html'),
      fixture('styles.css')
    ];

    var stream = inject('fixtures/template.html');

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function (newFile) {

      should.exist(newFile);
      should.exist(newFile.contents);

      String(newFile.contents).should.equal(String(expectedFile('defaults.html').contents));
      done();
    });

    sources.forEach(function (src) {
      stream.write(src);
    });

    stream.end();
  });

  it('should inject stylesheets, scripts and html components with `ignorePath` removed from file path', function (done) {

    var sources = [<commit_msg>Adding test to verify Issue #3 is fixed<commit_after>/*global describe, it*/
'use strict';

var fs = require('fs'),
  path = require('path'),
  should = require('should');
require('mocha');

var gutil = require('gulp-util'),
  inject = require('../');

function expectedFile (file) {
  var filepath = path.join('test/expected', file);
  return new gutil.File({
    path: filepath,
    cwd: 'test/',
    base: path.basename(filepath),
    contents: fs.readFileSync(filepath)
  });
}

function fixture (file) {
  var filepath = path.join('test/fixtures', file);
  return new gutil.File({
    path: filepath,
    cwd: 'test/',
    base: path.basename(filepath),
    contents: null
  });
}

describe('gulp-inject', function () {

  it('should inject stylesheets, scripts and html components into desired file', function (done) {

    var sources = [
      fixture('lib.js'),
      fixture('component.html'),
      fixture('styles.css')
    ];

    var stream = inject('fixtures/template.html');

    stream.on('error', function(err) {
      should.exist(err);
      done(err);
    });

    stream.on('data', function (newFile) {

      should.exist(newFile);
      should.exist(newFile.contents);
      newFile.base.should.equal(path.join(__dirname, 'fixtures'));

      String(newFile.contents).should.equal(String(expectedFile('defaults.html').contents));
      done();
    });

    sources.forEach(function (src) {
      stream.write(src);
    });

    stream.end();
  });

  it('should inject stylesheets, scripts and html components with `ignorePath` removed from file path', function (done) {

    var sources = [
{'fraction_non_alphanumeric': 0.16353203697800447, 'fraction_numerical': 0.000318775900541919, 'mean_word_length': 3.3583333333333334, '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': '3771841', 'n_tokens_mistral': 989, 'n_tokens_neox': 962, 'n_words': 225}