forked from berserker/microblog
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
838 B
30 lines
838 B
2 years ago
|
# 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
|