5 changed files with 91 additions and 47 deletions
@ -0,0 +1,40 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe TabNavHelper do |
||||||
|
let(:organisation) { FactoryBot.create(:organisation) } |
||||||
|
let(:user) { FactoryBot.build(:user, organisation: organisation) } |
||||||
|
|
||||||
|
describe "#user_cell" do |
||||||
|
it "returns user link and email separated by a newline character" do |
||||||
|
expected_html = "<a class=\"govuk-link\" href=\"/users\">Danny Rojas</a>\n#{user.email}" |
||||||
|
expect(user_cell(user)).to match(expected_html) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe "#org_cell" do |
||||||
|
it "returns the users org name and role separated by a newline character" do |
||||||
|
expected_html = "DLUHC\n<span class='app-!-colour-muted'>Data provider</span>" |
||||||
|
expect(org_cell(user)).to match(expected_html) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe "#tab_items" do |
||||||
|
context "user is a data_coordinator" do |
||||||
|
let(:user) { FactoryBot.build(:user, :data_coordinator, organisation: organisation) } |
||||||
|
it "returns details and user tabs" do |
||||||
|
result = tab_items(user).map { |i| i[:name] } |
||||||
|
expect(result.count).to eq(2) |
||||||
|
expect(result.first).to match("Details") |
||||||
|
expect(result.second).to match("Users") |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "user is a data_provider" do |
||||||
|
it "returns details tab only" do |
||||||
|
result = tab_items(user).map { |i| i[:name] } |
||||||
|
expect(result.count).to eq(1) |
||||||
|
expect(result.first).to match("Details") |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -1,19 +0,0 @@ |
|||||||
require "rails_helper" |
|
||||||
|
|
||||||
RSpec.describe UserTableHelper do |
|
||||||
let(:user) { FactoryBot.build(:user) } |
|
||||||
|
|
||||||
describe "#user_cell" do |
|
||||||
it "returns user link and email separated by a newline character" do |
|
||||||
expected_html = "<a class=\"govuk-link\" href=\"/users\">Danny Rojas</a>\n#{user.email}" |
|
||||||
expect(user_cell(user)).to match(expected_html) |
|
||||||
end |
|
||||||
end |
|
||||||
|
|
||||||
describe "#org_cell" do |
|
||||||
it "returns the users org name and role separated by a newline character" do |
|
||||||
expected_html = "DLUHC\n<span class='app-!-colour-muted'>Data provider</span>" |
|
||||||
expect(org_cell(user)).to match(expected_html) |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
Loading…
Reference in new issue