diff --git a/js/src/files-regular/add-from-fs.js b/js/src/files-regular/add-from-fs.js index b2f35cfa9..768277a03 100644 --- a/js/src/files-regular/add-from-fs.js +++ b/js/src/files-regular/add-from-fs.js @@ -44,6 +44,38 @@ module.exports = (createCommon, options) => { }) }) + it('should add a symlink to a file', (done) => { + const filePath = path.join(fixturesPath, 'symlinks', 'ipfs.txt-link') + ipfs.addFromFs(filePath, (err, files) => { + expect(err).to.not.exist() + + const file = files.find(r => r.path === 'ipfs.txt-link') + expect(file).to.exist() + + ipfs.cat(file.hash, (err, data) => { + expect(err).to.not.exist() + expect(data.toString()).to.eql('IPFS\n') + done() + }) + }) + }) + + it('should add a symlink to a directory', (done) => { + const dirPath = path.join(fixturesPath, 'symlinks', 'real-dir-link') + ipfs.addFromFs(dirPath, { recursive: true }, (err, files) => { + expect(err).to.not.exist() + + const file = files.find(r => r.path === 'real-dir-link/real-file.txt') + expect(file).to.exist() + + ipfs.cat(file.hash, (err, data) => { + expect(err).to.not.exist() + expect(data.toString()).to.eql('A real file\n') + done() + }) + }) + }) + it('should add a directory from the file system with an odd name', (done) => { const filesPath = path.join(fixturesPath, 'weird name folder [v0]') ipfs.addFromFs(filesPath, { recursive: true }, (err, result) => { diff --git a/js/test/fixtures/symlinks/ipfs.txt-link b/js/test/fixtures/symlinks/ipfs.txt-link new file mode 120000 index 000000000..a3cec95c3 --- /dev/null +++ b/js/test/fixtures/symlinks/ipfs.txt-link @@ -0,0 +1 @@ +../test-folder/files/ipfs.txt \ No newline at end of file diff --git a/js/test/fixtures/symlinks/real-dir-link b/js/test/fixtures/symlinks/real-dir-link new file mode 120000 index 000000000..08ca84305 --- /dev/null +++ b/js/test/fixtures/symlinks/real-dir-link @@ -0,0 +1 @@ +real-dir \ No newline at end of file diff --git a/js/test/fixtures/symlinks/real-dir/real-file.txt b/js/test/fixtures/symlinks/real-dir/real-file.txt new file mode 100644 index 000000000..6fdea282a --- /dev/null +++ b/js/test/fixtures/symlinks/real-dir/real-file.txt @@ -0,0 +1 @@ +A real file