spec/unicode_emoji_spec.rb in unicode-emoji-3.7.0 vs spec/unicode_emoji_spec.rb in unicode-emoji-3.8.0
- old
+ new
@@ -1,16 +1,16 @@
require_relative "../lib/unicode/emoji"
require "minitest/autorun"
describe Unicode::Emoji do
describe ".properties" do
- it "returns an Array for Emoji properties if has codepoints" do
+ it "returns an Array of Emoji properties for given codepoint" do
assert_equal ["Emoji", "Emoji_Presentation", "Extended_Pictographic"], Unicode::Emoji.properties("π΄")
assert_equal ["Emoji", "Extended_Pictographic"], Unicode::Emoji.properties("β ")
end
- it "returns nil for Emoji properties if has no codepoints" do
+ it "returns nil if codepoint has no Emoji prop" do
assert_nil Unicode::Emoji.properties("A")
end
end
describe "REGEX" do
@@ -90,10 +90,20 @@
it "matches recommended zwj sequences" do
"π€Ύπ½ββοΈ woman playing handball: medium skin tone" =~ Unicode::Emoji::REGEX
assert_equal "π€Ύπ½ββοΈ", $&
end
+ it "does not match MQE zwj sequences" do
+ "π€Ύπ½ββ woman playing handball: medium skin tone, missing VS16" =~ Unicode::Emoji::REGEX
+ refute_equal `π€Ύπ½ββ`, $&
+ end
+
+ it "does not match UQE emoji" do
+ "πββοΈ man golfing, missing VS16" =~ Unicode::Emoji::REGEX
+ refute_equal `πββοΈ`, $&
+ end
+
it "does not match valid zwj sequences that are not recommended" do
"π€ βπ€’ vomiting cowboy" =~ Unicode::Emoji::REGEX
assert_equal "π€ ", $&
end
@@ -130,16 +140,38 @@
it "matches 16.0 emoji" do
"πͺΎ leafless tree" =~ Unicode::Emoji::REGEX
assert_equal "πͺΎ", $&
end
-
-
# See gh#12 and https://github.com/matt17r/nw5k/commit/05a34d3c9211a23e5ae6853bb19fd2f224779ef4#diff-afb6f8bc3bae71b75743e00882a060863e2430cbe858ec9014e5956504dfc61cR2
it "matches family emoji correctly" do
["π¨βπ©βπ§βπ¦", "π¨βπ©βπ¦βπ¦", "π¨βπ©βπ§βπ§", "π¨βπ¨βπ§βπ¦", "π¨βπ¨βπ¦βπ¦", "π¨βπ¨βπ§βπ§", "π©βπ©βπ§βπ¦", "π©βπ©βπ¦βπ¦", "π©βπ©βπ§βπ§", "π¨βπ¦βπ¦", "π¨βπ§βπ¦", "π¨βπ§βπ§", "π©βπ¦βπ¦", "π©βπ§βπ¦", "π©βπ§βπ§"].each { |family|
assert_equal family, family[Unicode::Emoji::REGEX]
}
+ end
+ end
+
+ describe "REGEX_INCLUDE_MQE" do
+ it "matches MQE emoji" do
+ "π€Ύπ½ββ woman playing handball: medium skin tone, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE
+ assert_equal `π€Ύπ½ββ`, $&
+ end
+
+ it "does not match UQE emoji" do
+ "πββοΈ man golfing, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE
+ refute_equal `πββοΈ`, $&
+ end
+ end
+
+ describe "REGEX_INCLUDE_MQE_UQE" do
+ it "matches MQE emoji" do
+ "π€Ύπ½ββ woman playing handball: medium skin tone, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE_UQE
+ assert_equal `π€Ύπ½ββ`, $&
+ end
+
+ it "matches UQE emoji" do
+ "πββοΈ man golfing, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE_UQE
+ assert_equal `πββοΈ`, $&
end
end
describe "REGEX_VALID" do
it "matches most singleton emoji codepoints" do