plain_text_formatter_spec.rb 843 B

123456789101112131415161718192021222324
  1. require 'rails_helper'
  2. RSpec.describe PlainTextFormatter do
  3. describe '#to_s' do
  4. subject { described_class.new(status.text, status.local?).to_s }
  5. context 'given a post with local status' do
  6. let(:status) { Fabricate(:status, text: '<p>a text by a nerd who uses an HTML tag in text</p>', uri: nil) }
  7. it 'returns the raw text' do
  8. is_expected.to eq '<p>a text by a nerd who uses an HTML tag in text</p>'
  9. end
  10. end
  11. context 'given a post with remote status' do
  12. let(:remote_account) { Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') }
  13. let(:status) { Fabricate(:status, account: remote_account, text: '<p>Hello</p><script>alert("Hello")</script>') }
  14. it 'returns tag-stripped text' do
  15. is_expected.to eq 'Hello'
  16. end
  17. end
  18. end
  19. end