11/* eslint-env mocha */
22'use strict'
33
4+ const fs = require ( 'fs' )
5+ const path = require ( 'path' )
46const expect = require ( 'chai' ) . expect
57const pkgversion = require ( '../../package.json' ) . version
68const runOnAndOff = require ( '../utils/on-and-off' )
79
10+ function getRepoVersion ( repoPath ) {
11+ const versionPath = path . join ( repoPath , 'version' )
12+ return String ( fs . readFileSync ( versionPath ) )
13+ }
14+
815describe ( 'version' , ( ) => runOnAndOff ( ( thing ) => {
916 let ipfs
17+ let repoVersion
1018
1119 before ( ( ) => {
1220 ipfs = thing . ipfs
21+ repoVersion = getRepoVersion ( ipfs . repoPath )
1322 } )
1423
1524 it ( 'get the version' , ( ) => {
@@ -19,4 +28,32 @@ describe('version', () => runOnAndOff((thing) => {
1928 )
2029 } )
2130 } )
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+ } )
2259} ) )
0 commit comments