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