@@ -247,4 +247,55 @@ describe("emoji.js", function () {
247247 result . should . equal ( false ) ;
248248 } ) ;
249249 } ) ;
250+
251+ describe ( 'replace' , function ( ) {
252+ it ( 'Should be able to strip emojis' , function ( ) {
253+ var result = emoji . replace ( 'Host: eseaps001 Addr: 10.XX.XX.XX: - β οΈ γ°οΈ γ°οΈ low disk space' , '' , true ) ;
254+ result . should . equal ( 'Host: eseaps001 Addr: 10.XX.XX.XX: - low disk space' ) ;
255+ } ) ;
256+
257+ it ( 'Should keep the trailing spaces when not explicitly told to clean' , function ( ) {
258+ var result = emoji . replace ( 'Host: eseaps001 Addr: 10.XX.XX.XX: - β οΈ γ°οΈ γ°οΈ low disk space' , '' ) ;
259+ result . should . equal ( 'Host: eseaps001 Addr: 10.XX.XX.XX: - low disk space' ) ;
260+ } ) ;
261+
262+ it ( 'Should be able to strip a emoji by code text form' , function ( ) {
263+ var result = emoji . replace ( 'I β€ coffee' , '' , true ) ;
264+ result . should . equal ( 'I coffee' ) ;
265+ } ) ;
266+
267+ it ( 'Should be able to strip a emoji by code in variant form' , function ( ) {
268+ var result = emoji . replace ( 'I β€οΈ cleaning' , '' , true ) ;
269+ result . should . equal ( 'I cleaning' ) ;
270+ } ) ;
271+
272+ it ( 'Should be able to strip complex emojis' , function ( ) {
273+ var result = emoji . replace ( 'Where did this π©ββ€οΈβπβπ© happen?' , '' , true ) ;
274+ result . should . equal ( 'Where did this happen?' ) ;
275+ } ) ;
276+
277+ it ( 'Should be able to strip flag emojis' , function ( ) {
278+ var result = emoji . replace ( 'There is no flag π²π½' , '' , true ) ;
279+ result . should . equal ( 'There is no flag' ) ;
280+ } ) ;
281+
282+ it ( 'Should be able to replace by callback function' , function ( ) {
283+ var result = emoji . replace ( 'There is no β on my hard drive' , function ( emoji ) {
284+ return emoji . key ;
285+ } ) ;
286+ result . should . equal ( 'There is no warning on my hard drive' ) ;
287+ } ) ;
288+
289+ it ( 'Non existing complex emojis are known to be ignored' , function ( ) {
290+ var result = emoji . replace ( 'Some πβ€οΈβπββ emoji' , '' ) ;
291+ result . should . not . equal ( 'Some emoji' ) ;
292+ } ) ;
293+ } ) ;
294+
295+ describe ( 'strip' , function ( ) {
296+ it ( 'Should be able to strip emojis' , function ( ) {
297+ var result = emoji . strip ( 'Host: eseaps001 Addr: 10.XX.XX.XX: - β οΈ γ°οΈ γ°οΈ low disk space' ) ;
298+ result . should . equal ( 'Host: eseaps001 Addr: 10.XX.XX.XX: - low disk space' ) ;
299+ } ) ;
300+ } ) ;
250301} ) ;
0 commit comments