# frozen_string_literal: true require "spec_helper" describe ActiveCleaner::Utf8mb3Cleaner do let(:cleaner) { ActiveCleaner::Utf8mb3Cleaner.new(:title) } describe "#clean_value" do it "doesn't touch non string value" do expect(cleaner.clean_value(nil)).to eq(nil) expect(cleaner.clean_value(true)).to eq(true) expect(cleaner.clean_value(false)).to eq(false) expect(cleaner.clean_value(10)).to eq(10) end it "doesn't modify input string" do input = "Lorem ๐Ÿ˜ ipsum" expect { cleaner.clean_value(input) }.not_to change { input } end it "doesn't touch legit value" do expect(cleaner.clean_value("A good title!")).to eq("A good title!") end it "cleans emoticons" do emoticons = "๐Ÿ˜€๐Ÿ˜๐Ÿ˜‚๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‡๐Ÿ˜ˆ๐Ÿ˜‰๐Ÿ˜Š๐Ÿ˜‹๐Ÿ˜Œ๐Ÿ˜๐Ÿ˜Ž๐Ÿ˜๐Ÿ˜๐Ÿ˜‘๐Ÿ˜’๐Ÿ˜“๐Ÿ˜”๐Ÿ˜•๐Ÿ˜–๐Ÿ˜—๐Ÿ˜˜๐Ÿ˜™๐Ÿ˜š๐Ÿ˜›๐Ÿ˜œ๐Ÿ˜๐Ÿ˜ž๐Ÿ˜Ÿ๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ข๐Ÿ˜ฃ๐Ÿ˜ค๐Ÿ˜ฅ๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜จ๐Ÿ˜ฉ๐Ÿ˜ช๐Ÿ˜ซ๐Ÿ˜ฌ๐Ÿ˜ญ๐Ÿ˜ฎ๐Ÿ˜ฏ๐Ÿ˜ฐ๐Ÿ˜ฑ๐Ÿ˜ฒ๐Ÿ˜ณ๐Ÿ˜ด๐Ÿ˜ต๐Ÿ˜ถ๐Ÿ˜ท๐Ÿ˜ธ๐Ÿ˜น๐Ÿ˜บ๐Ÿ˜ป๐Ÿ˜ผ๐Ÿ˜ฝ๐Ÿ˜พ๐Ÿ˜ฟ๐Ÿ™€๐Ÿ™๐Ÿ™‚๐Ÿ™…๐Ÿ™†๐Ÿ™‡๐Ÿ™ˆ๐Ÿ™‰๐Ÿ™Š๐Ÿ™‹๐Ÿ™Œ๐Ÿ™๐Ÿ™Ž๐Ÿ™" expect(cleaner.clean_value("A good #{emoticons} title!")).to eq("A good title!") end it "kepts accentued chars" do expect(cleaner.clean_value("L'Inouรฏ Goรปter ร€ Manger.")).to eq("L'Inouรฏ Goรปter ร€ Manger.") end it "kepts japanese chars" do expect(cleaner.clean_value("ginkล is written as ้Š€่กŒ")).to eq("ginkล is written as ้Š€่กŒ") end end end