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
3 changed files
with
76 additions
and
4 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,30 @@ | ||
import { Client, Bus } from 'reventex/server'; | ||
|
||
const channel = 'throw-error'; | ||
|
||
it('throw-error', async () => { | ||
function* throwError({ subscribe, match, call, exit }) { | ||
yield subscribe(channel); | ||
|
||
yield match({ channel }, function*(event, { exit }) { | ||
yield exit(); | ||
}); | ||
|
||
yield call(() => { | ||
throw new Error(); | ||
}); | ||
|
||
yield exit(); | ||
} | ||
|
||
const bus = new Bus(); | ||
const client = new Client(throwError, bus); | ||
|
||
try { | ||
await client.run(); | ||
} catch (error) { | ||
return; | ||
} | ||
|
||
throw new Error(); | ||
}); |
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,30 @@ | ||
import { Client, Bus } from 'reventex/server'; | ||
|
||
const channel = 'unknown-command'; | ||
|
||
function unknown() {} | ||
|
||
it('unknown-command', async () => { | ||
function* unknownCommand({ subscribe, match, call, exit }) { | ||
yield subscribe(channel); | ||
|
||
yield match({ channel }, function*(event, { exit }) { | ||
yield exit(); | ||
}); | ||
|
||
yield unknown(); | ||
|
||
yield exit(); | ||
} | ||
|
||
const bus = new Bus(); | ||
const client = new Client(unknownCommand, bus); | ||
|
||
try { | ||
await client.run(); | ||
} catch (error) { | ||
return; | ||
} | ||
|
||
throw new Error(); | ||
}); |