1
+ /* eslint max-nested-callbacks: ["error", 5] */
1
2
/* eslint-env mocha */
2
3
'use strict'
3
4
5
+ const os = require ( 'os' )
4
6
const expect = require ( 'chai' ) . expect
7
+ const repoVersion = require ( 'ipfs-repo' ) . repoVersion
5
8
const pkgversion = require ( '../../package.json' ) . version
6
9
const runOnAndOff = require ( '../utils/on-and-off' )
7
10
@@ -12,11 +15,55 @@ describe('version', () => runOnAndOff((thing) => {
12
15
ipfs = thing . ipfs
13
16
} )
14
17
15
- it ( 'get the version' , ( ) => {
16
- return ipfs ( 'version' ) . then ( ( out ) => {
18
+ it ( 'get the version' , ( ) =>
19
+ ipfs ( 'version' ) . then ( out =>
17
20
expect ( out ) . to . eql (
18
21
`js-ipfs version: ${ pkgversion } \n`
19
22
)
20
- } )
23
+ )
24
+ )
25
+
26
+ it ( 'handles --number' , ( ) =>
27
+ ipfs ( 'version --number' ) . then ( out =>
28
+ expect ( out ) . to . eql ( `${ pkgversion } \n` )
29
+ )
30
+ )
31
+
32
+ it ( 'handles --commit' , ( ) =>
33
+ ipfs ( 'version --commit' ) . then ( out =>
34
+ expect ( out ) . to . eql ( `js-ipfs version: ${ pkgversion } -\n` )
35
+ )
36
+ )
37
+
38
+ describe ( 'handles --all' , function ( ) {
39
+ it ( 'prints js-ipfs version' , ( ) =>
40
+ ipfs ( 'version --all' ) . then ( out => {
41
+ expect ( out ) . to . include ( `js-ipfs version: ${ pkgversion } ` )
42
+ } )
43
+ )
44
+
45
+ it ( 'prints repo version' , ( ) =>
46
+ ipfs ( 'version --all' ) . then ( out => {
47
+ expect ( out ) . to . include ( `Repo version: ${ repoVersion } ` )
48
+ } )
49
+ )
50
+
51
+ it ( 'prints arch/platform' , ( ) =>
52
+ ipfs ( 'version --all' ) . then ( out => {
53
+ expect ( out ) . to . include ( `System version: ${ os . arch ( ) } /${ os . platform ( ) } ` )
54
+ } )
55
+ )
56
+
57
+ it ( 'prints Node.js version' , ( ) =>
58
+ ipfs ( 'version --all' ) . then ( out => {
59
+ expect ( out ) . to . include ( `Node.js version: ${ process . version } ` )
60
+ } )
61
+ )
21
62
} )
63
+
64
+ it ( 'handles --repo' , ( ) =>
65
+ ipfs ( 'version --repo' ) . then ( out =>
66
+ expect ( out ) . to . eql ( `${ repoVersion } \n` )
67
+ )
68
+ )
22
69
} ) )
0 commit comments