-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
34 lines (26 loc) · 1.1 KB
/
test.js
File metadata and controls
34 lines (26 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import fs from 'fs-extra';
import { homedir } from 'os';
import test from 'ava';
import path from 'path';
import commitCount from './index';
const fixtures = path.join(process.cwd(), 'test', 'fixtures');
test.before('rename git folders', () => {
fs.renameSync(path.join(fixtures, 'git-commit-0', 'git'), path.join(fixtures, 'git-commit-0', '.git'));
fs.renameSync(path.join(fixtures, 'git-commit-1', 'git'), path.join(fixtures, 'git-commit-1', '.git'));
});
test.after.always('rename .git folders', () => {
fs.renameSync(path.join(fixtures, 'git-commit-0', '.git'), path.join(fixtures, 'git-commit-0', 'git'));
fs.renameSync(path.join(fixtures, 'git-commit-1', '.git'), path.join(fixtures, 'git-commit-1', 'git'));
});
test('check if process.cwd() has commits', (t) => {
t.not(commitCount(), 0);
});
test('check if home dir has commits', (t) => {
t.is(commitCount(homedir()), -1);
});
test('check if another dir has commits', (t) => {
t.is(commitCount('./test/fixtures/git-commit-1'), 1);
});
test('check if another dir has commits', (t) => {
t.is(commitCount('./test/fixtures/git-commit-0'), 0);
});