Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 29dc5c4

Browse files
committed
Adjust to new cli test + add get test
1 parent 700f4b6 commit 29dc5c4

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

test/cli/test-files.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@ const path = require('path')
88
const describeOnlineAndOffline = require('../utils/on-and-off')
99
const ipfs = require('../utils/ipfs-exec')(repoPath)
1010

11-
describe('files', () => {
11+
describe.only('files', () => {
1212
describeOnlineAndOffline(repoPath, () => {
1313
it('cat', () => {
1414
return ipfs('files cat QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o').then((out) => {
1515
expect(out).to.be.eql('hello world')
1616
})
1717
})
18-
it('add alias', (done) => {
19-
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'add', 'src/init-files/init-docs/readme'], {env})
20-
.run((err, stdout, exitcode) => {
21-
expect(err).to.not.exist
22-
expect(exitcode).to.equal(0)
23-
expect(stdout[0]).to.equal('added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme')
24-
done()
25-
})
18+
it('cat alias', () => {
19+
return ipfs('cat QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o').then((out) => {
20+
expect(out).to.be.eql('hello world')
21+
})
2622
})
2723

2824
it('get', () => {
@@ -41,6 +37,22 @@ describe('files', () => {
4137
fs.unlinkSync(file)
4238
})
4339
})
40+
it('get alias', () => {
41+
return ipfs('get QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o').then((out) => {
42+
expect(out).to.be.eql(
43+
'Saving file(s) to QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'
44+
)
45+
46+
const file = path.join(process.cwd(), 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o')
47+
expect(
48+
fs.readFileSync(file).toString()
49+
).to.be.eql(
50+
'hello world\n'
51+
)
52+
53+
fs.unlinkSync(file)
54+
})
55+
})
4456

4557
it('add', () => {
4658
return ipfs('files add src/init-files/init-docs/readme').then((out) => {
@@ -50,6 +62,14 @@ describe('files', () => {
5062
})
5163
})
5264

65+
it('add alias', () => {
66+
return ipfs('files add src/init-files/init-docs/readme').then((out) => {
67+
expect(out).to.be.eql(
68+
'added QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme'
69+
)
70+
})
71+
})
72+
5373
it('add recursively', () => {
5474
return ipfs('files add -r src/init-files/init-docs').then((out) => {
5575
expect(out).to.be.eql([

0 commit comments

Comments
 (0)