-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
44 lines (31 loc) · 1.26 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
import { homedir } from 'os';
import test from 'ava';
import execa from 'execa';
import fs from 'fs-extra';
import isGit from './';
const isGitRequired = require('./');
const randomString = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 10);
test.serial('check if something is added in process.cwd() - manipulated', (t) => {
fs.writeFileSync(`test_generated_${randomString}.js`, 'console.log();');
execa.sync('git', ['add', `test_generated_${randomString}.js`]);
const isGitValue = isGit();
const isGitRequiredValue = isGitRequired();
execa.sync('git', ['reset', 'HEAD', `test_generated_${randomString}.js`]);
fs.removeSync(`test_generated_${randomString}.js`);
t.true(isGitValue);
t.true(isGitRequiredValue);
});
test.serial('check if something is just changed in process.cwd() - manipulated', (t) => {
fs.writeFileSync(`test_generated_${randomString}.js`, 'console.log();');
const isGitValue = isGit();
const isGitRequiredValue = isGitRequired();
fs.removeSync(`test_generated_${randomString}.js`);
t.false(isGitValue);
t.false(isGitRequiredValue);
});
test('check if something is added in process.cwd()', (t) => {
t.false(isGit());
});
test('check if something is added in users home', (t) => {
t.false(isGit(homedir()));
});