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.

35 lines
1009 B

  1. require 'rails_helper'
  2. RSpec.describe StreamEntriesHelper, type: :helper do
  3. describe '#display_name' do
  4. it 'uses the display name when it exists' do
  5. account = Account.new(display_name: "Display", username: "Username")
  6. expect(helper.display_name(account)).to eq "Display"
  7. end
  8. it 'uses the username when display name is nil' do
  9. account = Account.new(display_name: nil, username: "Username")
  10. expect(helper.display_name(account)).to eq "Username"
  11. end
  12. end
  13. describe '#rtl?' do
  14. it 'is false if text is empty' do
  15. expect(helper).not_to be_rtl ''
  16. end
  17. it 'is false if there are no right to left characters' do
  18. expect(helper).not_to be_rtl 'hello world'
  19. end
  20. it 'is false if right to left characters are fewer than 1/3 of total text' do
  21. expect(helper).not_to be_rtl 'hello ݟ world'
  22. end
  23. it 'is true if right to left characters are greater than 1/3 of total text' do
  24. expect(helper).to be_rtl 'aaݟ'
  25. end
  26. end
  27. end