about summary refs log tree commit diff
path: root/spec/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-07-17 23:10:31 +0200
committerGitHub <noreply@github.com>2022-07-17 23:10:31 +0200
commitab1488a6ad93f572e1d184cb9653f76fd408474f (patch)
treef1dd126f4745eb99243f390169fb957a72f5acc6 /spec/lib
parent325ebb76b19bd20e1b76d8bc26c11cab02f6571c (diff)
parent6c0d73a675d62f676b005c06593fd69e9a7bc0e5 (diff)
Merge pull request #1804 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/hashtag_normalizer_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/lib/hashtag_normalizer_spec.rb b/spec/lib/hashtag_normalizer_spec.rb
new file mode 100644
index 000000000..fbb9f37c0
--- /dev/null
+++ b/spec/lib/hashtag_normalizer_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe HashtagNormalizer do
+  subject { described_class.new }
+
+  describe '#normalize' do
+    it 'converts full-width Latin characters into basic Latin characters' do
+      expect(subject.normalize('Synthwave')).to eq 'synthwave'
+    end
+
+    it 'converts half-width Katakana into Kana characters' do
+      expect(subject.normalize('シーサイドライナー')).to eq 'シーサイドライナー'
+    end
+
+    it 'converts modified Latin characters into basic Latin characters' do
+      expect(subject.normalize('BLÅHAJ')).to eq 'blahaj'
+    end
+
+    it 'strips out invalid characters' do
+      expect(subject.normalize('#foo')).to eq 'foo'
+    end
+
+    it 'keeps valid characters' do
+      expect(subject.normalize('a·b')).to eq 'a·b'
+    end
+  end
+end