Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

require "rails_helper"
RSpec.describe DetailsTableHelper do
describe "details html" do
3 years ago
let(:details) { details_html(attribute) }
2 weeks ago
let(:current_user) { FactoryBot.build(:user) }
context "when given a simple attribute" do
3 years ago
let(:attribute) { { name: "name", value: "Dummy org", editable: true } }
it "displays the string wrapped in a p" do
expect(details).to eq("<p class=\"govuk-body\">Dummy org</p>")
end
end
2 weeks ago
context "when given a bullet point list of attributes" do
3 years ago
let(:list) { %w[Camden Westminster Bristol] }
let(:attribute) do
{
name: "local_authorities_operated_in",
value: list,
editable: false,
format: :bullet,
}
end
it "displays the string wrapped in an unordered list with the correct classes" do
expect(details).to eq("<ul class=\"govuk-list govuk-list--bullet\"><li>Camden</li><li>Westminster</li><li>Bristol</li></ul>")
end
end
2 weeks ago
context "when given a bullet point list with one attribute" do
let(:list) { %w[Camden] }
let(:attribute) do
{
name: "local_authorities_operated_in",
value: list,
editable: false,
format: :bullet,
}
end
it "displays the string wrapped in a p" do
expect(details).to eq("<p class=\"govuk-body\">Camden</p>")
end
end
2 weeks ago
context "when given an attribute value is empty" do
let(:attribute) { { value: "" } }
it "displays the default message" do
expect(details_html(attribute)).to include("No answer provided")
end
end
context "when given an attribute value is not empty" do
let(:attribute) { { value: "Dummy text" } }
it "displays the default message" do
expect(details_html(attribute)).to include("Dummy text")
end
end
end
end