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