about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorJoël Quenneville <joel.quen@gmail.com>2017-04-21 18:13:37 -0400
committerEugen <eugen@zeonfederated.com>2017-04-22 00:13:37 +0200
commit974ac467de5a60a30dc3d19b8ced732e04395879 (patch)
treea2acf21b97956ffd047a2fdab93c1ce687848f12 /spec
parentaf7d02da5d2ec014fb87765b65b23d7b3ed6c90c (diff)
Add tests for StreamEntriesHelper#rtl? (#2286)
We used some random Arabic characters to test that the various RTL
conditions got triggered.
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/stream_entries_helper_spec.rb18
1 files changed, 18 insertions, 0 deletions
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