File tree Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Expand file tree Collapse file tree 2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ import { getMessageMock } from '../test/mocks';
55
66describe ( 'thx' , ( ) => {
77 let id = 0 ;
8- const msgReply = 'protip: napisz `@nazwa ++`, żeby komuś podziękować! Możesz podziękować kilku osobom w jednej wiadomości!' ;
8+ const msgReply =
9+ 'protip: napisz `@nazwa ++`, żeby komuś podziękować! Możesz podziękować kilku osobom w jednej wiadomości!' ;
910
1011 it ( 'it should ignore random messages' , async ( ) => {
1112 const msg = getMessageMock ( 'msg' , { content : 'msg' , channel : { id : ++ id } } ) ;
@@ -16,14 +17,26 @@ describe('thx', () => {
1617 expect ( msg . reply ) . not . to . have . been . calledOnceWith ( msgReply ) ;
1718 } ) ;
1819
19- it ( 'it should respond to thanks' , async ( ) => {
20- const msg = getMessageMock ( 'msg' , { content : 'dzięki' , channel : { id : ++ id } } ) ;
21- msg . reply . resolves ( ) ;
20+ [
21+ 'thx' ,
22+ 'thank' ,
23+ 'thanks' ,
24+ 'dzieki' ,
25+ 'dzięki' ,
26+ 'dziekuje' ,
27+ 'dziekuję' ,
28+ 'dziękuje' ,
29+ 'dziękuję' ,
30+ ] . forEach ( ( text ) =>
31+ it ( `it should respond to ${ text } ` , async ( ) => {
32+ const msg = getMessageMock ( 'msg' , { content : text , channel : { id : ++ id } } ) ;
33+ msg . reply . resolves ( ) ;
2234
23- await thx ( msg as unknown as Discord . Message ) ;
35+ await thx ( msg as unknown as Discord . Message ) ;
2436
25- expect ( msg . reply ) . to . have . been . calledOnceWith ( msgReply ) ;
26- } ) ;
37+ expect ( msg . reply ) . to . have . been . calledOnceWith ( msgReply ) ;
38+ } ) ,
39+ ) ;
2740
2841 [
2942 'dzięki temu' ,
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const thxTimeoutCache = new Cache({ stdTTL: THX_TIMEOUT_S });
66
77export const thx = ( msg : Discord . Message ) => {
88 if (
9- ! / ( t h x | t h a n k | d z i ę k i | d z i ę k u j ę | d z i e k i | d z i e k u j e ) ( $ | ( \s + (? ! t e m u | n i e j | n i e m u | t o b i e ) + .* ) ) / i. test (
9+ ! / ( t h x | t h a n k | t h a n k s | d z i [ e | ę ] k i | d z i [ e | ę ] k u j [ e | ę ] ) ( $ | ( \s + (? ! t e m u | n i e j | n i e m u | t o b i e | n i m ) + .* ) ) / i. test (
1010 msg . content ,
1111 )
1212 ) {
@@ -21,5 +21,7 @@ export const thx = (msg: Discord.Message) => {
2121 }
2222
2323 thxTimeoutCache . set ( msg . channel . id , new Date ( ) ) ;
24- return msg . reply ( 'protip: napisz `@nazwa ++`, żeby komuś podziękować! Możesz podziękować kilku osobom w jednej wiadomości!' ) ;
24+ return msg . reply (
25+ 'protip: napisz `@nazwa ++`, żeby komuś podziękować! Możesz podziękować kilku osobom w jednej wiadomości!' ,
26+ ) ;
2527} ;
You can’t perform that action at this time.
0 commit comments