Skip to content

Commit

Permalink
Merge pull request #2448 from alphagov/add-manual-section-test
Browse files Browse the repository at this point in the history
added spec file for manual section test
  • Loading branch information
KludgeKML authored May 25, 2022
2 parents 063601c + 736402c commit baa39e7
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions test/presenters/content_item/manual_section_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
require "test_helper"

class ContentItemManualSectionTest < ActiveSupport::TestCase
class DummyContentItem
attr_reader :manual_page_title, :content_item, :manual, :base_path
attr_accessor :details

include ContentItem::ManualSection
def initialize
@content_item = {}
@content_item["title"] = "manualsectiontest"
@manual_page_title = @content_item["title"]
@details = { "section_id" => "ADML1000" }
@manual = { "title" => "harrypotter" }
@base_path = "/a/base/path"
end
end

test "returns title" do
item = DummyContentItem.new

assert_equal("harrypotter", item.title)
end

test "returns page title" do
item = DummyContentItem.new

assert_equal("ADML1000 - manualsectiontest", item.page_title)
end

test "returns document_heading" do
item = DummyContentItem.new

assert_equal(%w[ADML1000 manualsectiontest], item.document_heading)
end

test "returns breadcrumb when section_id is present" do
item = DummyContentItem.new

assert_equal("ADML1000", item.breadcrumb)
end

test "returns breadcrumb when section_id not present" do
item = DummyContentItem.new

item.details = {}

assert_equal("harrypotter", item.breadcrumb)
end

test "returns manual_content_item" do
stub_request(:get, "https://content-store.test.gov.uk/content/a/base/path")
.with(
headers: {
"Accept" => "application/json",
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
"Host" => "content-store.test.gov.uk",
"User-Agent" => "gds-api-adapters/79.1.2 ()",
},
)
.to_return(status: 200, body: "{}", headers: {})
item = DummyContentItem.new

assert_equal({}, item.manual_content_item.parsed_content)
end
end

0 comments on commit baa39e7

Please sign in to comment.