This repository has been archived by the owner on May 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var Baker = require('../lib/baker'); | ||
var buster = require('buster-node'); | ||
var referee = require('referee'); | ||
var webshot = require('webshot'); | ||
var assert = referee.assert; | ||
|
||
buster.testCase('breaker - _iterPostsByTags', { | ||
setUp: function () { | ||
this.mockConsole = this.mock(console); | ||
}, | ||
'should pass error to callback when error occurred while retrieving posts': function (done) { | ||
this.mockConsole.expects('log').once().withExactArgs('* tag: %s', 'tag1'.cyan); | ||
var mockEggtart = { | ||
posts: function () { | ||
return { | ||
recent: function (opts, cb) { | ||
cb(new Error('some error')); | ||
} | ||
}; | ||
} | ||
}; | ||
var baker = new Baker(mockEggtart); | ||
baker._iterPostsByTags(['tag1', 'tag2'], null, function (err, result) { | ||
assert.equals(err.message, 'some error'); | ||
done(); | ||
}); | ||
}, | ||
'should log message when no posts found': function (done) { | ||
this.mockConsole.expects('log').once().withExactArgs('* tag: %s', 'tag1'.cyan); | ||
this.mockConsole.expects('log').once().withExactArgs('* tag: %s', 'tag2'.cyan); | ||
this.mockConsole.expects('log').twice().withExactArgs('%s - %s', 'warn'.yellow, 'No bookmark found'); | ||
var mockEggtart = { | ||
posts: function () { | ||
return { | ||
recent: function (opts, cb) { | ||
cb(null, {}); | ||
} | ||
}; | ||
} | ||
}; | ||
var baker = new Baker(mockEggtart); | ||
baker._iterPostsByTags(['tag1', 'tag2'], null, function (err, result) { | ||
assert.equals(err, undefined); | ||
done(); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var bag = require('bagofcli'); | ||
var Baker = require('../lib/baker'); | ||
var buster = require('buster-node'); | ||
var cli = require('../lib/cli'); | ||
var referee = require('referee'); | ||
var assert = referee.assert; | ||
|
||
buster.testCase('cli - exec', { | ||
'should contain commands with actions': function (done) { | ||
var mockCommand = function (base, actions) { | ||
assert.defined(base); | ||
assert.defined(actions.commands.delete.action); | ||
assert.defined(actions.commands.screenshot.action); | ||
done(); | ||
}; | ||
this.mock({}); | ||
this.stub(bag, 'command', mockCommand); | ||
cli.exec(); | ||
} | ||
}); | ||
|
||
buster.testCase('cli - delete', { | ||
setUp: function () { | ||
this.mock({}); | ||
}, | ||
'should contain delete command and delegate to baker delete when exec is called': function (done) { | ||
this.stub(bag, 'command', function (base, actions) { | ||
actions.commands.delete.action({ tags: 'tag1,tag2', parent: {} }); | ||
}); | ||
this.stub(Baker.prototype, 'delete', function (tags, cb) { | ||
assert.equals(tags, ['tag1', 'tag2']); | ||
assert.equals(typeof cb, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
}, | ||
'should pass empty array when tags arg is not provided': function (done) { | ||
this.stub(bag, 'command', function (base, actions) { | ||
actions.commands.delete.action({ parent: {} }); | ||
}); | ||
this.stub(Baker.prototype, 'delete', function (tags, cb) { | ||
assert.equals(tags, []); | ||
assert.equals(typeof cb, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
} | ||
}); | ||
|
||
buster.testCase('cli - screenshot', { | ||
setUp: function () { | ||
this.mock({}); | ||
}, | ||
'should contain screenshot command and delegate to baker screenshot when exec is called': function (done) { | ||
this.stub(bag, 'command', function (base, actions) { | ||
actions.commands.screenshot.action({ tags: 'tag1,tag2', parent: { userPass: 'someusername:somepassword' } }); | ||
}); | ||
this.stub(Baker.prototype, 'screenshot', function (tags, cb) { | ||
assert.equals(tags, ['tag1', 'tag2']); | ||
assert.equals(typeof cb, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
}, | ||
'should pass empty array when tags arg is not provided': function (done) { | ||
this.stub(bag, 'command', function (base, actions) { | ||
actions.commands.screenshot.action({ parent: { userPass: 'someusername:somepassword' } }); | ||
}); | ||
this.stub(Baker.prototype, 'screenshot', function (tags, cb) { | ||
assert.equals(tags, []); | ||
assert.equals(typeof cb, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
} | ||
}); |