From 974ac467de5a60a30dc3d19b8ced732e04395879 Mon Sep 17 00:00:00 2001 From: Joël Quenneville Date: Fri, 21 Apr 2017 18:13:37 -0400 Subject: Add tests for StreamEntriesHelper#rtl? (#2286) We used some random Arabic characters to test that the various RTL conditions got triggered. --- spec/helpers/stream_entries_helper_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec/helpers') diff --git a/spec/helpers/stream_entries_helper_spec.rb b/spec/helpers/stream_entries_helper_spec.rb index e2544e311..706a872f1 100644 --- a/spec/helpers/stream_entries_helper_spec.rb +++ b/spec/helpers/stream_entries_helper_spec.rb @@ -14,4 +14,22 @@ RSpec.describe StreamEntriesHelper, type: :helper do expect(helper.display_name(account)).to eq "Username" end end + + describe '#rtl?' do + it 'is false if text is empty' do + expect(helper).not_to be_rtl '' + end + + it 'is false if there are no right to left characters' do + expect(helper).not_to be_rtl 'hello world' + end + + it 'is false if right to left characters are fewer than 1/3 of total text' do + expect(helper).not_to be_rtl 'hello ݟ world' + end + + it 'is true if right to left characters are greater than 1/3 of total text' do + expect(helper).to be_rtl 'aaݟ' + end + end end -- cgit