# frozen_string_literal: true require 'rails_helper' RSpec.describe PlainTextFormatter do describe '#to_s' do subject { described_class.new(status.text, status.local?).to_s } context 'when status is local' do let(:status) { Fabricate(:status, text: '
a text by a nerd who uses an HTML tag in text
', uri: nil) } it 'returns the raw text' do expect(subject).to eq 'a text by a nerd who uses an HTML tag in text
' end end context 'when status is remote' do let(:remote_account) { Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') } context 'when text contains inline HTML tags' do let(:status) { Fabricate(:status, account: remote_account, text: 'Lorem ipsum') } it 'strips the tags' do expect(subject).to eq 'Lorem ipsum' end end context 'when text containstags' do let(:status) { Fabricate(:status, account: remote_account, text: '
Lorem
ipsum
') } it 'inserts a newline' do expect(subject).to eq "Lorem\nipsum" end end context 'when text contains a singleLorem 明日 ipsum
') } it 'strips the comment' do expect(subject).to eq 'Lorem 明日 (Ashita) ipsum' end end end end end