forked from bower/bower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.js
89 lines (69 loc) · 2.79 KB
/
version.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var expect = require('expect.js');
var helpers = require('../helpers');
var version = helpers.require('lib/commands').version;
describe('bower list', function () {
var package = new helpers.TempDir({
'bower.json': {
name: 'foobar',
version: '0.0.0'
}
});
var gitPackage = new helpers.TempDir({
'v0.0.0': {
'bower.json': {
name: 'foobar',
version: '0.0.0'
}
}
});
it('bumps patch version', function() {
package.prepare();
return helpers.run(version, ['patch', {}, { cwd: package.path }]).then(function() {
expect(package.readJson('bower.json').version).to.be('0.0.1');
});
});
it('bumps minor version', function() {
package.prepare();
return helpers.run(version, ['minor', {}, { cwd: package.path }]).then(function() {
expect(package.readJson('bower.json').version).to.be('0.1.0');
});
});
it('bumps major version', function() {
package.prepare();
return helpers.run(version, ['major', {}, { cwd: package.path }]).then(function() {
expect(package.readJson('bower.json').version).to.be('1.0.0');
});
});
it('changes version', function() {
package.prepare();
return helpers.run(version, ['1.2.3', {}, { cwd: package.path }]).then(function() {
expect(package.readJson('bower.json').version).to.be('1.2.3');
});
});
it('returns the new version', function() {
package.prepare();
return helpers.run(version, ['major', {}, { cwd: package.path }]).then(function(results) {
expect(results[0]).to.be('1.0.0');
});
});
it('bumps patch version, create commit, and tag', function() {
gitPackage.prepareGit();
return helpers.run(version, ['patch', {}, { cwd: gitPackage.path }]).then(function() {
expect(gitPackage.readJson('bower.json').version).to.be('0.0.1');
var tags = gitPackage.git('tag');
expect(tags).to.be('v0.0.0\nv0.0.1\n');
var message = gitPackage.git('log', '--pretty=format:%s', '-n1');
expect(message).to.be('v0.0.1');
});
});
it('bumps with custom commit message', function() {
gitPackage.prepareGit();
return helpers.run(version, ['patch', { message: 'Bumping %s, because what'}, { cwd: gitPackage.path }]).then(function() {
expect(gitPackage.readJson('bower.json').version).to.be('0.0.1');
var tags = gitPackage.git('tag');
expect(tags).to.be('v0.0.0\nv0.0.1\n');
var message = gitPackage.git('log', '--pretty=format:%s', '-n1');
expect(message).to.be('Bumping 0.0.1, because what');
});
});
});