spec/unicode_emoji_spec.rb in unicode-emoji-1.1.0 vs spec/unicode_emoji_spec.rb in unicode-emoji-2.0.0
- old
+ new
@@ -156,11 +156,11 @@
assert_equal "π΄σ §σ ’σ ‘σ §σ ’σ Ώ", $&
end
it "does not match invalid tag sequences" do
"π΄σ §σ ’σ ‘σ ‘σ ‘σ Ώ GB AAA" =~ Unicode::Emoji::REGEX_VALID
- assert_equal "π΄", $&
+ assert_equal "π΄", $& # only base flag is matched
end
it "matches recommended zwj sequences" do
"π€Ύπ½ββοΈ woman playing handball: medium skin tone" =~ Unicode::Emoji::REGEX_VALID
assert_equal "π€Ύπ½ββοΈ", $&
@@ -170,10 +170,92 @@
"π€ βπ€’ vomiting cowboy" =~ Unicode::Emoji::REGEX_VALID
assert_equal "π€ βπ€’", $&
end
end
+ describe "REGEX_WELL_FORMED" do
+ it "matches most singleton emoji codepoints" do
+ "π΄ sleeping face" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΄", $&
+ end
+
+ it "matches singleton emoji in combination with emoji variation selector" do
+ "π΄\u{FE0F} sleeping face" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΄\u{FE0F}", $&
+ end
+
+ it "does not match singleton emoji when in combination with text variation selector" do
+ "π΄\u{FE0E} sleeping face" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_nil $&
+ end
+
+ it "does not match textual singleton emoji" do
+ "βΆ play button" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_nil $&
+ end
+
+ it "matches textual singleton emoji in combination with emoji variation selector" do
+ "βΆ\u{FE0F} play button" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "βΆ\u{FE0F}", $&
+ end
+
+ it "does not match singleton 'component' emoji codepoints" do
+ "π» light skin tone" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_nil $&
+ end
+
+ it "matches modified emoji if modifier base emoji is used" do
+ "ππ½ person in bed: medium skin tone" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "ππ½", $&
+ end
+
+ it "does not match modified emoji if no modifier base emoji is used" do
+ "π΅π½ cactus" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΅", $&
+ end
+
+ it "matches valid region flags" do
+ "π΅πΉ Portugal" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΅πΉ", $&
+ end
+
+ it "does match invalid region flags" do
+ "π΅π΅ PP Land" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΅π΅", $&
+ end
+
+ it "matches emoji keycap sequences" do
+ "2οΈβ£ keycap: 2" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "2οΈβ£", $&
+ end
+
+ it "matches recommended tag sequences" do
+ "π΄σ §σ ’σ ³σ £σ ΄σ Ώ Scotland" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΄σ §σ ’σ ³σ £σ ΄σ Ώ", $&
+ end
+
+ it "matches valid tag sequences, even though they are not recommended" do
+ "π΄σ §σ ’σ ‘σ §σ ’σ Ώ GB AGB" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΄σ §σ ’σ ‘σ §σ ’σ Ώ", $&
+ end
+
+ it "does match invalid tag sequences" do
+ "π΄σ §σ ’σ ‘σ ‘σ ‘σ Ώ GB AAA" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π΄σ §σ ’σ ‘σ ‘σ ‘σ Ώ", $&
+ end
+
+ it "matches recommended zwj sequences" do
+ "π€Ύπ½ββοΈ woman playing handball: medium skin tone" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π€Ύπ½ββοΈ", $&
+ end
+
+ it "matches valid zwj sequences, even though they are not recommended" do
+ "π€ βπ€’ vomiting cowboy" =~ Unicode::Emoji::REGEX_WELL_FORMED
+ assert_equal "π€ βπ€’", $&
+ end
+ end
+
describe "REGEX_BASIC" do
it "matches most singleton emoji codepoints" do
"π΄ sleeping face" =~ Unicode::Emoji::REGEX_BASIC
assert_equal "π΄", $&
end
@@ -298,17 +380,23 @@
end
end
describe ".list" do
it "returns a grouped list of emoji" do
- assert_includes Unicode::Emoji.list.keys, "Smileys & People"
+ assert_includes Unicode::Emoji.list.keys, "Smileys & Emotion"
end
it "sub-groups the list of emoji" do
- assert_includes Unicode::Emoji.list("Smileys & People").keys, "face-positive"
+ assert_includes Unicode::Emoji.list("Smileys & Emotion").keys, "face-glasses"
end
it "has emoji in sub-groups" do
- assert_includes Unicode::Emoji.list("Smileys & People", "face-positive"), "π"
+ assert_includes Unicode::Emoji.list("Smileys & Emotion", "face-glasses"), "π"
+ end
+
+ it "issues a warning if attempting to retrieve old category" do
+ assert_output nil, "Warning(unicode-emoji): The category of Smileys & People does not exist anymore\n" do
+ assert_nil Unicode::Emoji.list("Smileys & People", "face-positive")
+ end
end
end
end