Skip to content

Commit

Permalink
add simple-git dependency & ocnvert tests
Browse files Browse the repository at this point in the history
  • Loading branch information
titaniumbones committed Oct 2, 2019
1 parent e808eea commit ff06942
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 39 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"dependencies": {
"cheerio": "^1.0.0-rc.3",
"jquery": "^3.4.1",
"jsdom": "^15.1.1"
"jsdom": "^15.1.1",
"simple-git": "^1.126.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
62 changes: 24 additions & 38 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
// start by requiring all relevant modules
const path = require('path'), // find paths
fs=require('fs'), // deal w/ filesystem
simpleGit = require('simple-git/promise'),
// gitCommits = require('git-commits'), // git stuff -- should al lbe updated in 2020
gitConfig = require('git-config'),
//gitConfig = require('git-config'),
// gitState = require('git-state'),
cheerio=require('cheerio'), // should get rid of this is poss in favor of jsdom
hwc = require('html-word-count'); // important!
shwc = require('html-word-count'); // important!

const chai=require('chai'), // testing stuff
expect=chai.expect, // stupidly using both assert and expect
Expand All @@ -22,7 +21,8 @@ const { JSDOM } = require('jsdom');
// allow file system tests
chai.use(require('chai-fs'));

var repoPath = path.resolve(process.env.REPO || (__dirname ));
const repoPath = path.resolve(process.env.REPO || (__dirname )),
simpleGit = require('simple-git/promise')
const ignoreCommitEmails = ['[email protected]']; // ignore my own commits

// get repo path
Expand All @@ -45,20 +45,8 @@ let studentCommits = 0,


// global vars for path tests
let name,email,githubid; // we'll need these throughout

// set the config vars
gitConfig(function (err, config) {
if (err) return done(err);
if (config.user.name) {name = config.user.name;}
if (config.user.email) {email = config.user.email;}
if (config.github.user) {githubid = config.github.user;}

});

// let name,email,githubid; // really only needed in git section?

// more variables to be used later
var links = [];
// const index = fs.readFileSync(indexPath, 'utf8');
const problem1 = fs.readFileSync(path.join('01', 'index.html'), 'utf8'),
problem2 = fs.readFileSync(path.join('02', 'index.html'), 'utf8');
Expand All @@ -73,29 +61,27 @@ const problem1 = fs.readFileSync(path.join('01', 'index.html'), 'utf8'),

describe('Git Checks', function() {
//return this.skip;
var gitCheck;
let gitCheck;
const email = simpleGit(__dirname).raw(['config', '--get', 'user.email']);
const githubid = simpleGit(__dirname).raw(['config', '--get', 'github.user']);
const name = simpleGit(__dirname).raw(['config', '--get', 'user.name']);

before(function(done) {
simpleGit (repoPath)
.log()
.then (
(log) => {
const lg = simpleGit(repoPath).log()
const st = simpleGit (repoPath).status()
lg.then ( (log) => {
// console.log(log);
for (let l of log.all) {
// console.log(l.author_email);
if (!matchesProfEmail(l['author_email'], ignoreCommitEmails) )
{
studentCommits++;
}
}
// console.log("studentcommits: " + studentCommits)
})
.then( () => {
simpleGit (repoPath).status().then( (status) => {
// console.log(status);
gitCheck=status.files.length;
})})
.then(done())

for (let l of log.all) {
// console.log(l.author_email);
if (!matchesProfEmail(l['author_email'], ignoreCommitEmails) )
{ studentCommits++; }
}
})
st.then( (status) => {
// console.log(status);
gitCheck=status.files.length;
})
Promise.all([lg, st]).then( () => { done()})
});

it('You should have made at least ' + minCommits + ' git commits ', function() {
Expand Down

0 comments on commit ff06942

Please sign in to comment.