-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
33 lines (25 loc) · 1.04 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
import fs from 'fs';
import { homedir } from 'os';
import test from 'ava';
import path from 'path';
import branchName from './index';
const fixtures = path.join(process.cwd(), 'test', 'fixtures');
const folders = [
'feat_test',
'master',
];
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('check if the given directory is the branch master', (t) => {
t.is(branchName({ altPath: path.join(fixtures, 'master'), branchOptions: '--no-color' }), 'master');
});
test('check if the given directory is the branch feat/test', (t) => {
t.is(branchName({ altPath: path.join(fixtures, 'feat_test'), branchOptions: '--no-color' }), 'feat_test');
});
test('check the branch name of the home dir', (t) => {
t.false(branchName({ altPath: homedir(), branchOptions: '--no-color' }));
});