-
Notifications
You must be signed in to change notification settings - Fork 80
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
1 parent
eac6acc
commit 26d7691
Showing
15 changed files
with
1,829 additions
and
1,818 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
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,63 @@ | ||
const path = require('path'); | ||
|
||
const test = require('ava'); | ||
|
||
const Bree = require('../src'); | ||
|
||
const root = path.join(__dirname, 'jobs'); | ||
|
||
test('successfully add jobs as array', (t) => { | ||
const bree = new Bree({ | ||
root, | ||
jobs: ['infinite'] | ||
}); | ||
|
||
t.is(typeof bree.config.jobs[1], 'undefined'); | ||
|
||
bree.add(['basic']); | ||
|
||
t.is(typeof bree.config.jobs[1], 'object'); | ||
}); | ||
|
||
test('successfully add job not array', (t) => { | ||
const bree = new Bree({ | ||
root, | ||
jobs: ['infinite'] | ||
}); | ||
|
||
t.is(typeof bree.config.jobs[1], 'undefined'); | ||
|
||
bree.add('basic'); | ||
|
||
t.is(typeof bree.config.jobs[1], 'object'); | ||
}); | ||
|
||
test('fails if job already exists', (t) => { | ||
const bree = new Bree({ | ||
root, | ||
jobs: ['basic'] | ||
}); | ||
|
||
t.throws(() => bree.add(['basic']), { | ||
message: /Job .* has a duplicate job name of */ | ||
}); | ||
}); | ||
|
||
test('successfully adds job object', (t) => { | ||
const bree = new Bree({ root: false }); | ||
function noop() {} | ||
bree.add({ name: 'basic', path: noop.toString() }); | ||
t.pass(); | ||
}); | ||
|
||
test('missing job name', (t) => { | ||
const logger = {}; | ||
logger.error = () => {}; | ||
logger.info = () => {}; | ||
|
||
const bree = new Bree({ | ||
root: false, | ||
logger | ||
}); | ||
t.throws(() => bree.add(), { message: /Job .* is missing a name/ }); | ||
}); |
Oops, something went wrong.