]> cat aescling's git repositories - mastodon.git/blob - spec/lib/formatter_spec.rb
Merge pull request #3 from tootsuite/master
[mastodon.git] / spec / lib / formatter_spec.rb
1 require 'rails_helper'
2
3 RSpec.describe Formatter do
4 let(:account) { Fabricate(:account, username: 'alice') }
5 let(:local_status) { Fabricate(:status, text: 'Hello world http://google.com', account: account) }
6 let(:remote_status) { Fabricate(:status, text: '<script>alert("Hello")</script> Beep boop', uri: 'beepboop', account: account) }
7
8 describe '#format' do
9 subject { Formatter.instance.format(local_status) }
10
11 it 'returns a string' do
12 expect(subject).to be_a String
13 end
14
15 it 'contains plain text' do
16 expect(subject).to match('Hello world')
17 end
18
19 it 'contains a link' do
20 expect(subject).to match('<a rel="nofollow noopener" target="_blank" href="http://google.com"><span class="invisible">http://</span><span class="ellipsis">google.com</span><span class="invisible"></span></a>')
21 end
22 end
23
24 describe '#reformat' do
25 subject { Formatter.instance.format(remote_status) }
26
27 it 'returns a string' do
28 expect(subject).to be_a String
29 end
30
31 it 'contains plain text' do
32 expect(subject).to match('Beep boop')
33 end
34
35 it 'does not contain scripts' do
36 expect(subject).to_not match('<script>alert("Hello")</script>')
37 end
38 end
39 end
This page took 0.079052 seconds and 5 git commands to generate.