1
1
/* eslint-env mocha */
2
2
'use strict'
3
3
4
+ const fs = require ( 'fs' )
5
+ const path = require ( 'path' )
4
6
const expect = require ( 'chai' ) . expect
5
7
const pkgversion = require ( '../../package.json' ) . version
6
8
const runOnAndOff = require ( '../utils/on-and-off' )
7
9
10
+ function getRepoVersion ( repoPath ) {
11
+ const versionPath = path . join ( repoPath , 'version' )
12
+ return String ( fs . readFileSync ( versionPath ) )
13
+ }
14
+
8
15
describe ( 'version' , ( ) => runOnAndOff ( ( thing ) => {
9
16
let ipfs
17
+ let repoVersion
10
18
11
19
before ( ( ) => {
12
20
ipfs = thing . ipfs
21
+ repoVersion = getRepoVersion ( ipfs . repoPath )
13
22
} )
14
23
15
24
it ( 'get the version' , ( ) => {
@@ -19,4 +28,32 @@ describe('version', () => runOnAndOff((thing) => {
19
28
)
20
29
} )
21
30
} )
31
+
32
+ it ( 'handles --number' , ( ) => {
33
+ return ipfs ( 'version --number' ) . then ( out =>
34
+ expect ( out ) . to . eql ( `${ pkgversion } \n` )
35
+ )
36
+ } )
37
+
38
+ it ( 'handles --commit' , ( ) => {
39
+ return ipfs ( 'version --commit' ) . then ( out =>
40
+ expect ( out ) . to . eql ( `js-ipfs version: ${ pkgversion } -\n` )
41
+ )
42
+ } )
43
+
44
+ it ( 'handles --all' , ( ) => {
45
+ return ipfs ( 'version --all' ) . then ( out =>
46
+ expect ( out ) . to . include (
47
+ `js-ipfs version: ${ pkgversion } -
48
+ Repo version: ${ repoVersion }
49
+ `
50
+ )
51
+ )
52
+ } )
53
+
54
+ it ( 'handles --repo' , ( ) => {
55
+ return ipfs ( 'version --repo' ) . then ( out => {
56
+ expect ( out ) . to . eql ( `${ repoVersion } \n` )
57
+ } )
58
+ } )
22
59
} ) )
0 commit comments