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

var should = require("should"),
  git = require("../lib/git");

require("mocha");

describe("gulp-gitmodified", function () {

  it("should have mockable which and exec", function (done) {
    var fnCalls = 0;
    git.which = function (app, cb) {
      ++fnCalls;
      app.should.equal("git");
      cb();
    };
    git.exec = function (app, args, extra, cb) {
      ++fnCalls;
      app.should.equal("git");
      cb(null, "");
    };
    git.getStatusByMatcher(/\\s/, function (err) {
      should(err).equal(null);
      fnCalls.should.equal(2);
      done();
    });
  });

  // More tests to come.

});
<commit_msg>Adds more tests for git module.<commit_after>/*global describe, it*/
"use strict";

var should = require("should"),
  git = require("../lib/git");

require("mocha");

describe("gulp-gitmodified", function () {

  it("should have mockable which and exec", function (done) {
    var fnCalls = 0;
    git.which = function (app, cb) {
      ++fnCalls;
      app.should.equal("git");
      cb();
    };
    git.exec = function (app, args, extra, cb) {
      ++fnCalls;
      app.should.equal("git");
      cb(null, "");
    };
    git.getStatusByMatcher(/\\s/, function (err) {
      should(err).equal(null);
      fnCalls.should.equal(2);
      done();
    });
  });


  it("should give error if git is not found on the system", function (done) {
    git.which = function (app, cb) {
      cb(new Error());
    };
    git.exec = function (app, args, extra, cb) {
      cb(null, "");
    };
    git.getStatusByMatcher(/\\s/, function (err) {
      should(err.message).equal("git not found on your system.");
      done();
    });
  });

  it("should return a file returned by git status", function (done) {
    git.which = function (app, cb) {
      cb();
    };
    git.exec = function (app, args, extra, cb) {
      cb(null, "M index.js");
    };
    git.getStatusByMatcher(/M\s/i, function (err, data) {
      should.not.exist(err);
      should.exist(data);
      should.exist(data[0]);
      data[0].should.equal('index.js');
      done();
    });
  });


  it("should return several files from git status", function (done) {
    git.which = function (app, cb) {
      cb();
    };
    git.exec = function (app, args, extra, cb) {
      cb(null, "M index.js\nM foo.js\nM bar.js");
    };
    git.getStatusByMatcher(/M\s/i, function (err, data) {
      should.not.exist(err);
      should.exist(data);
      should.exist(data[0]);
      data.length.should.equal(3);
      done();
    });
  });

  it("should ignore statused files that doesnt match pattern", function (done) {
    git.which = function (app, cb) {
      cb();
    };
    git.exec = function (app, args, extra, cb) {
      cb(null, "M index.js\nD foo.js\nM bar.js");
    };
    git.getStatusByMatcher(/M\s/i, function (err, data) {
      should.not.exist(err);
      should.exist(data);
      should.exist(data[0]);
      data.length.should.equal(2);
      done();
    });
  });

});

{'fraction_non_alphanumeric': 0.18656963281508435, 'fraction_numerical': 0.0033079722130334105, 'mean_word_length': 2.4402730375426622, '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': '5232123', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1019, 'n_words': 239}