-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(mw/allow-chat): Add test from mw (#22)
- Loading branch information
Shelomanov
committed
Dec 3, 2017
1 parent
ffb40b0
commit dc2ca2c
Showing
2 changed files
with
55 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,39 @@ | ||
import test from 'ava' | ||
import { Context, next } from '../tests/telegraf' | ||
import { allowWhiteListChat } from './allowed-chat' | ||
|
||
/* eslint-disable no-param-reassign */ | ||
|
||
test.beforeEach((t) => { | ||
t.context.ctx = Context.create() | ||
}) | ||
|
||
test('test public chat not in the white list', async (t) => { | ||
t.context.ctx.chat.$type('public') | ||
t.context.ctx.chat.$inWhiteList(false) | ||
|
||
t.is(await allowWhiteListChat(t.context.ctx, next), null) | ||
}) | ||
|
||
test('test public chat in the white list', async (t) => { | ||
t.context.ctx.chat.$type('public') | ||
t.context.ctx.chat.$inWhiteList(true) | ||
|
||
try { | ||
await allowWhiteListChat(t.context.ctx, next(() => t.pass())) | ||
} | ||
catch (error) { | ||
t.fail() | ||
} | ||
}) | ||
|
||
test('test private chat', async (t) => { | ||
t.context.ctx.chat.$type('private') | ||
|
||
try { | ||
await allowWhiteListChat(t.context.ctx, next(() => t.pass())) | ||
} | ||
catch (error) { | ||
t.fail() | ||
} | ||
}) |
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