Skip to content

Commit

Permalink
Add tests for --output. Update cli usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeriopvl committed Jul 31, 2015
1 parent 5a5cfd7 commit cff53fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ module.exports = function (argv) {
};

function showHelp() {
console.log('Usage: downstagram [-m|--metadata] <username>');
console.log('Usage: downstagram [-m|--metadata] [-o|--output] <username>');
console.log('Options:')
console.log(' --metadata: for every media file also create a metadata json file');
console.log(' --output <path>: define a custom path where the photos will be saved');
}

function showVersion() {
Expand Down
15 changes: 14 additions & 1 deletion test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('downstagram module', function (t) {

var Downstagram = require('../lib/downstagram.js');

mockFS({ 'media-mock.jpg': 'just a media file mock' });
mockFS({ 'media-mock.jpg': 'just a media file mock', '/tmp': {} });

t.test('instance has start method', function (t) {
t.plan(1);
Expand Down Expand Up @@ -78,6 +78,19 @@ test('downstagram module', function (t) {
});
d.start();
});

t.test('when passing --output saves files in the custom dir', function (t) {
t.plan(3);
var expectedFolderPath = path.join('/tmp', 'rogeriopvl_instagram_photos');

var d = new Downstagram('rogeriopvl', { output: '/tmp' });
d.on('end', function () {
t.ok(fs.existsSync(expectedFolderPath));
t.ok(fs.existsSync(path.join(expectedFolderPath, '1438270800.jpg')));
t.ok(fs.existsSync(path.join(expectedFolderPath, '1438270899.mp4')));
});
d.start();
});
}).on('end', function () {
mockFS.restore();
Mockery.deregisterAll();
Expand Down

0 comments on commit cff53fa

Please sign in to comment.