-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
48 lines (37 loc) · 1.14 KB
/
test.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import test from 'ava';
import fs from 'fs-extra';
import { homedir } from 'os';
import path from 'path';
import isGit from './index';
const fixtures = path.join(process.cwd(), 'test', 'fixtures');
const folders = [
'squashed',
'needsPushJustLocal',
'needsPush',
'upToDate',
'detached',
];
test.before('rename git folders', () => {
folders.map(folder => fs.renameSync(path.join(fixtures, folder, 'git'), path.join(fixtures, folder, '.git')));
});
test.after.always('rename .git folders', () => {
folders.map(folder => fs.renameSync(path.join(fixtures, folder, '.git'), path.join(fixtures, folder, 'git')));
});
test('up to date', (t) => {
t.false(isGit(path.join(fixtures, 'upToDate')));
});
test('needs to push', (t) => {
t.true(isGit(path.join(fixtures, 'needsPush')));
});
test('squashed', (t) => {
t.true(isGit(path.join(fixtures, 'squashed')));
});
test('detached', (t) => {
t.false(isGit(path.join(fixtures, 'detached')));
});
test('a local branch needs to get pushed', (t) => {
t.true(isGit(path.join(fixtures, 'needsPushJustLocal')));
});
test('homedir should not be a git repo', (t) => {
t.false(isGit(homedir()));
});