-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.js
63 lines (50 loc) · 1.43 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
var assert = require('assert');
var gitLatestSemverTag = require('./');
var shell = require('shelljs');
var writeFileSync = require('fs').writeFileSync;
shell.config.silent = true;
shell.rm('-rf', 'tmp');
shell.mkdir('tmp');
shell.cd('tmp');
shell.exec('git init');
it('should error if no commits found', function(done) {
gitLatestSemverTag(function(err) {
assert(err);
writeFileSync('test1', '');
shell.exec('git add --all && git commit -m"First commit"');
shell.exec('git tag foo');
done();
});
});
it('should get no semver tag', function(done) {
gitLatestSemverTag(function(err, tag) {
assert.equal(tag, '');
writeFileSync('test2', '');
shell.exec('git add --all && git commit -m"Second commit"');
shell.exec('git tag v2.0.0');
writeFileSync('test3', '');
shell.exec('git add --all && git commit -m"Third commit"');
shell.exec('git tag va.b.c');
done();
});
});
it('should get the latest semver tag', function(done) {
gitLatestSemverTag(function(err, tag) {
assert.equal(tag, 'v2.0.0');
shell.exec('git tag v3.0.0');
done();
});
});
it('should get the correct latest semver tag', function(done) {
gitLatestSemverTag(function(err, tag) {
assert.equal(tag, 'v3.0.0');
done();
});
});
it('should ensure it works if I run it again', function(done) {
gitLatestSemverTag(function(err, tag) {
assert.equal(tag, 'v3.0.0');
done();
});
});