-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add enabled function to a task - fixes #42
- Loading branch information
1 parent
7f44533
commit 477964d
Showing
5 changed files
with
143 additions
and
6 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
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
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,60 @@ | ||
import {serial as test} from 'ava'; | ||
import Listr from '../'; | ||
This comment has been minimized.
Sorry, something went wrong.
sindresorhus
|
||
import SimpleRenderer from './fixtures/simple-renderer'; | ||
import {testOutput} from './fixtures/utils'; | ||
|
||
test('do not run disabled tasks', async t => { | ||
const list = new Listr([ | ||
{ | ||
title: 'foo', | ||
task: () => Promise.resolve() | ||
}, | ||
{ | ||
title: 'bar', | ||
enabled: ctx => ctx.run === true, | ||
task: () => Promise.resolve() | ||
} | ||
], { | ||
renderer: SimpleRenderer | ||
}); | ||
|
||
testOutput(t, [ | ||
'foo [started]', | ||
'foo [completed]', | ||
'done' | ||
]); | ||
|
||
await list.run(); | ||
}); | ||
|
||
test('run enabled task', async t => { | ||
const list = new Listr([ | ||
{ | ||
title: 'foo', | ||
task: (ctx, task) => Promise.reject(new Error('Something went wrong')) | ||
.catch(() => { | ||
task.skip('It failed'); | ||
|
||
ctx.failed = true; | ||
}) | ||
}, | ||
{ | ||
title: 'bar', | ||
enabled: ctx => ctx.failed === true, | ||
task: () => Promise.resolve() | ||
} | ||
], { | ||
renderer: SimpleRenderer | ||
}); | ||
|
||
testOutput(t, [ | ||
'foo [started]', | ||
'foo [skipped]', | ||
'> It failed', | ||
'bar [started]', | ||
'bar [completed]', | ||
'done' | ||
]); | ||
|
||
await list.run(); | ||
}); |
Wouldn't it make more sense to make all these getter properties?