require 'rails_helper'
require 'smart_annotations/html_preview'
describe SmartAnnotations::HtmlPreview do
let(:subject) { described_class }
let(:user) { create :user }
let(:project) { create :project, name: 'my project' }
let(:experiment) do
create :experiment, name: 'my experiment',
project: project,
created_by: user,
last_modified_by: user
end
let(:task) { create :my_module, name: 'task', experiment: experiment }
describe 'Project annotations with type prj' do
it 'returns a html snippet' do
snippet = subject.html(nil, 'prj', project)
expect(snippet).to eq(
"Prj " \
"my project"
)
end
end
context 'Experiment annotations with type exp' do
it 'returns a html snippet' do
snippet = subject.html(nil, 'exp', experiment)
expect(snippet).to eq(
"Exp " \
"my experiment"
)
end
end
context 'MyModule annotations with type tsk' do
it 'returns a html snippet' do
snippet = subject.html(nil, 'tsk', task)
expect(snippet).to eq(
"Tsk " \
"task"
)
end
end
context 'Repository item annotations with type rep_item' do
it 'returns a html snippet' do
snippet = subject.html('my item', 'rep_item', nil)
expect(snippet).to eq(
'Rep my item (deleted)'
)
end
end
describe '#trim_repository_name/1' do
it 'is returns a 3 letter upcase string' do
trimmed_repository_name = subject.__send__(
:trim_repository_name, 'banana'
)
expect(trimmed_repository_name).to eq('Ban')
end
end
end