about summary refs log tree commit diff
path: root/spec/lib/hashtag_normalizer_spec.rb
blob: fbb9f37c07076b3ec2c78141980d534a7e075876 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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