@@ -134,6 +134,20 @@ describe('Filter', () => {
134
134
filter . init ( ) ;
135
135
expect ( filter . replaceText ( 'You deserve an A+' ) ) . to . equal ( 'You deserve an __' ) ;
136
136
} ) ;
137
+
138
+ it ( 'Ending with tilde' , ( ) => {
139
+ const filter = new Filter ;
140
+ filter . cfg = new Config ( {
141
+ censorCharacter : '_' ,
142
+ filterMethod : Constants . FILTER_METHODS . CENSOR ,
143
+ preserveFirst : false ,
144
+ words : {
145
+ 'waves~' : { matchMethod : Constants . MATCH_METHODS . EXACT } ,
146
+ } ,
147
+ } ) ;
148
+ filter . init ( ) ;
149
+ expect ( filter . replaceText ( 'Look at those waves~' ) ) . to . equal ( 'Look at those ______' ) ;
150
+ } ) ;
137
151
} ) ;
138
152
139
153
describe ( 'Partial' , ( ) => {
@@ -186,6 +200,22 @@ describe('Filter', () => {
186
200
expect ( filter . replaceText ( 'I love allthis! Do you?' ) ) . to . equal ( 'I love all_____ Do you?' ) ;
187
201
expect ( filter . replaceText ( 'I love this! Do you?' ) ) . to . equal ( 'I love _____ Do you?' ) ;
188
202
} ) ;
203
+
204
+ it ( 'Ending with brackets and braces' , ( ) => {
205
+ const filter = new Filter ;
206
+ filter . cfg = new Config ( {
207
+ censorCharacter : '_' ,
208
+ filterMethod : Constants . FILTER_METHODS . CENSOR ,
209
+ preserveFirst : false ,
210
+ words :{
211
+ '{cool}' : { matchMethod : Constants . MATCH_METHODS . PARTIAL } ,
212
+ '[tag]' : { matchMethod : Constants . MATCH_METHODS . PARTIAL } ,
213
+ } ,
214
+ } ) ;
215
+ filter . init ( ) ;
216
+ expect ( filter . replaceText ( 'Check the [tag] for the sale' ) ) . to . equal ( 'Check the _____ for the sale' ) ;
217
+ expect ( filter . replaceText ( 'You are so {cool}!' ) ) . to . equal ( 'You are so ______!' ) ;
218
+ } ) ;
189
219
} ) ;
190
220
191
221
describe ( 'Whole' , ( ) => {
@@ -832,6 +862,19 @@ describe('Filter', () => {
832
862
expect ( filter . replaceText ( 'I love this!' ) ) . to . equal ( 'I love' ) ;
833
863
} ) ;
834
864
865
+ it ( 'Ending with semicolon' , ( ) => {
866
+ const filter = new Filter ;
867
+ filter . cfg = new Config ( {
868
+ filterMethod : Constants . FILTER_METHODS . REMOVE ,
869
+ words : {
870
+ 'and more;' : { matchMethod : Constants . MATCH_METHODS . EXACT , repeat : Constants . FALSE } ,
871
+ } ,
872
+ } ) ;
873
+ filter . init ( ) ;
874
+ expect ( filter . replaceText ( 'and more;' ) ) . to . equal ( '' ) ;
875
+ expect ( filter . replaceText ( 'you can have it all, and more;' ) ) . to . equal ( 'you can have it all,' ) ;
876
+ } ) ;
877
+
835
878
it ( 'With separators' , ( ) => {
836
879
const filter = new Filter ;
837
880
filter . cfg = new Config ( {
@@ -874,6 +917,35 @@ describe('Filter', () => {
874
917
expect ( filter . replaceText ( 'I love allthis! Do you?' ) ) . to . equal ( 'I love Do you?' ) ;
875
918
expect ( filter . replaceText ( 'I love this! Do you?' ) ) . to . equal ( 'I love Do you?' ) ;
876
919
} ) ;
920
+
921
+ it ( 'Ending with colon' , ( ) => {
922
+ const filter = new Filter ;
923
+ filter . cfg = new Config ( {
924
+ filterMethod : Constants . FILTER_METHODS . REMOVE ,
925
+ words : {
926
+ 'app. rate:' : { matchMethod : Constants . MATCH_METHODS . PARTIAL , repeat : Constants . FALSE } ,
927
+ } ,
928
+ } ) ;
929
+ filter . init ( ) ;
930
+ expect ( filter . replaceText ( 'app. rate:' ) ) . to . equal ( '' ) ;
931
+ expect ( filter . replaceText ( 'app. rate: 5.93%' ) ) . to . equal ( '5.93%' ) ;
932
+ } ) ;
933
+
934
+ it ( 'Ending with special characters' , ( ) => {
935
+ const filter = new Filter ;
936
+ filter . cfg = new Config ( {
937
+ filterMethod : Constants . FILTER_METHODS . REMOVE ,
938
+ words : {
939
+ 'check-mate/' : { matchMethod : Constants . MATCH_METHODS . PARTIAL , repeat : Constants . FALSE } ,
940
+ 'cheese()' : { matchMethod : Constants . MATCH_METHODS . PARTIAL , repeat : Constants . FALSE } ,
941
+ '{cake' : { matchMethod : Constants . MATCH_METHODS . PARTIAL , repeat : Constants . FALSE } ,
942
+ } ,
943
+ } ) ;
944
+ filter . init ( ) ;
945
+ expect ( filter . replaceText ( 'Surprise! Check-mate/' ) ) . to . equal ( 'Surprise!' ) ;
946
+ expect ( filter . replaceText ( 'Say cheese()' ) ) . to . equal ( 'Say' ) ;
947
+ expect ( filter . replaceText ( 'Do you want any {cake' ) ) . to . equal ( 'Do you want any' ) ;
948
+ } ) ;
877
949
} ) ;
878
950
879
951
it ( 'Should filter a RegExp' , ( ) => {
0 commit comments