mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-18 23:21:30 +08:00
7f7bf0533a
* Fix tests [SCI-6486] * Fix rspec tests [SCI-6486] Co-authored-by: Anton <anton@scinote.net>
44 lines
1.3 KiB
Ruby
44 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe SmartAnnotations::TextPreview do
|
|
let(:subject) { described_class }
|
|
let(:user) { create :user }
|
|
let(:project) { create :project, name: 'my project', created_by: user }
|
|
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, created_by: experiment.created_by }
|
|
|
|
describe 'Project annotations' do
|
|
it 'returns a text snippet' do
|
|
snippet = subject.text(nil, 'prj', project)
|
|
expect(snippet).to eq(project.name)
|
|
end
|
|
end
|
|
|
|
context 'Experiment annotations' do
|
|
it 'returns a text snippet' do
|
|
snippet = subject.text(nil, 'exp', experiment)
|
|
expect(snippet).to eq(experiment.name)
|
|
end
|
|
end
|
|
|
|
context 'MyModule annotations' do
|
|
it 'returns a text snippet' do
|
|
snippet = subject.text(nil, 'tsk', task)
|
|
expect(snippet).to eq(task.name)
|
|
end
|
|
end
|
|
|
|
context 'Repository item annotations with type rep_item' do
|
|
it 'returns a html snippet' do
|
|
snippet = subject.text('my item', 'rep_item', nil)
|
|
expect(snippet).to eq('my item (deleted)')
|
|
end
|
|
end
|
|
end
|