Skip to content

Commit

Permalink
Merge pull request #10 from n4ze3m/0.0.10
Browse files Browse the repository at this point in the history
latest emojis
  • Loading branch information
n4ze3m committed Aug 21, 2023
2 parents aede141 + 223a2f9 commit 35dfbd3
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 0.0.10

+ new emoji unicode added

## 0.0.9

+ `0.0.8` unfortunately remove chinese characters so new regex added to fix this issue
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2020 Buckthorn Dev
Copyright (c) 2023 Muhammed Nazeem

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 26 additions & 1 deletion example/remove_emoji_example.dart
Expand Up @@ -10,7 +10,32 @@ void main() {
.removEmoji);
// other language
print('5 rue des écoles. la quantiné 75000 Paris🤣🥂'.removEmojiNoTrim);
// chinese characters
print('你好🙄世界🌬🌫🌨⛈⛈🌨'.removEmoji);
// japanese characters
print('こんに🙄ちは世界🌬🌫🌨⛈⛈🌨'.removEmoji);
// arabic characters
print('مرحبا با🙄🙄لعالم🌬🌫🌨⛈⛈🌨'.removEmoji);
// russian characters
print('При🙄🙄вет мир🌬🌫🌨⛈⛈🌨'.removEmoji);
// malayalam characters
print('ഹ🙄🙄ലോ ലോകം🌬🌫🌨⛈⛈🌨'.removEmoji);
// hindi characters
print('नमस्ते दुनि🙄🙄या🌬🌫🌨⛈⛈🌨'.removEmoji);
// ukranian characters
print('Пр🙄🙄ивіт світ🌬🌫🌨⛈⛈🌨'.removEmoji);
// spanish characters
print('Hola M🙄🙄undo🌬🌫🌨⛈⛈🌨'.removEmoji);
// tamil characters
print('ஹ🙄🙄லோ உலகம்🌬🌫🌨⛈⛈🌨'.removEmoji);
// vietnamese characters
print('Xin chào thế giới🌬🌫🌨⛈⛈🌨'.removEmoji);
// thai characters
print('ส🙄🙄วัสดีชาวโลก🌬🌫🌨⛈⛈🌨'.removEmoji);
// korean characters
print('안🙄🙄녕하세요 세계🌬🌫🌨⛈⛈🌨'.removEmoji);
// flags
print('🇩🇲test'.removEmoji);
// get the regex string
// this function will help you to get the regex string and use it in your own code
print(remove.getRegexString());
}
8 changes: 7 additions & 1 deletion lib/src/remove_emoji_base.dart
Expand Up @@ -37,6 +37,12 @@ class RemoveEmoji {
///```
String clean(String text, [String word = '', bool trimText = true]) =>
trimText
? text.replaceAll(RegExp(r), word).trim()
? text
.replaceAll(
RegExp(
r,
),
word)
.trim()
: text.replaceAll(RegExp(r), word);
}
3 changes: 1 addition & 2 deletions lib/src/util/emoji.dart

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,6 +1,6 @@
name: remove_emoji
description: Dart and flutter package accurately replace/remove emojis in text
version: 0.0.9
version: 0.0.10
homepage: https://github.com/n4ze3m/remove-emoji

environment:
Expand Down
67 changes: 23 additions & 44 deletions test/remove_emoji_test.dart
@@ -1,23 +1,14 @@
import 'package:test/test.dart';
import 'package:remove_emoji/remove_emoji.dart';

// ----------------------------------------------------------------------------
// Test Setup Stuff
RemoveEmoji remove = RemoveEmoji();
String testDataWithSpace =
' 🤣h😌e🙄l😪l😓o😳🤔👨‍🦰🤶🏿 🧝‍♂️🍝🥘🌯🍦🥂🥂🎂🍰🧁🍨🍧😁w🤷‍♂️o😎r🤪l🤦‍♂️d🐸🤑😆😖🎉🍾🤟🤩😢🐭😡😍📧😄😔😇🧐😈🙁🤓🙂🥱🌬🌫🌨⛈⛈🌨 ';
String testDataWithSpace = ' 😁h🤔e🤭l😐l🏃🏻🏻o 😅w🤣o👋🏻r😻l🤨d😄 ';

// ----------------------------------------------------------------------------
// Actual Test
void main() {
group('clean Extension Tests', () {
test('trimText = true (default) Validation', () {
expect(testDataWithSpace.removEmoji, 'hello world');
});

test('trimText = false (override) Validation', () {
expect(testDataWithSpace.removEmojiNoTrim, ' hello world ');
});
});

group('RemoveEmoji Class Tests', () {
Expand All @@ -30,54 +21,42 @@ void main() {
});
});

// group('Emoji 14 test', () {
// test('testing 🌬🌫🌨⛈⛈🌨', () {
// expect(remove.clean('testing 🌬🌫🌨⛈⛈🌨'), 'testing');
// });

// test('🫨 Oh wow', () {
// expect(remove.clean('🫨 Oh wow', ''), 'Oh wow');
// });
// });

// group('Emoji 15 test', () {
// test('testing 🪭', () {
// expect(remove.clean('testing 🪭'), 'testing');
// });

// test('nice 🫸 🌬🌫🌨⛈⛈🌨', () {
// expect(remove.clean('nice 🫸 🌬🌫🌨⛈⛈🌨'), 'nice');
// });
// });

// test with chinese characters and emoji "你好世界"
group('Chinese characters and emoji test', () {
test('你好世界', () {
expect(remove.clean('你好世界'), '你好世界');
group('Emoji 14 test', () {
test('testing 🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('testing 🌬🌫🌨⛈⛈🌨'), 'testing');
});

test('你好世界🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('你好世界🌬🌫🌨⛈⛈🌨'), '你好世界');
test('🫨 Oh wow', () {
expect(remove.clean('🫨 Oh wow', ''), 'Oh wow');
});
});

test('你好世界🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('你好世界🌬🌫🌨⛈⛈🌨'), '你好世界');
group('Emoji 15 test', () {
test('testing 🪭', () {
expect(remove.clean('testing 🪭'), 'testing');
});

test('你好世界🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('你好世界🌬🌫🌨⛈⛈🌨'), '你好世界');
test('nice 🫸 🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('nice 🫸 🌬🌫🌨⛈⛈🌨'), 'nice');
});
});

test('你好世界🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('你好世界🌬🌫🌨⛈⛈🌨'), '你好世界');
group('Chinese characters and emoji test', () {
test('你好世界', () {
expect(remove.clean('你好世界 '), '你好世界');
});

test('你好世界🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('你好世界🌬🌫🌨⛈⛈🌨'), '你好世界');
});
});

test('你好世界🌬🌫🌨⛈⛈🌨', () {
expect(remove.clean('你好世界🌬🌫🌨⛈⛈🌨'), '你好世界');
group('Latest Emojis', () {
test('🇨🇳T🇺🇸🇦🇪🇬🇧E🏴🏁🫣🫨🫨🫨S🫨🫨🫨🫲🏻🫱🏿💪🦾💩🤡T', () {
expect(
remove
.clean('🇨🇳T🇺🇸🇦🇪🇬🇧E🏴🏁🫣🫨🫨🫨S🫨🫨🫨🫲🏻🫱🏿💪🦾💩🤡T'),
'TEST');
});
});
}

0 comments on commit 35dfbd3

Please sign in to comment.