Skip to content

Commit baa39e7

Browse files
authored
Merge pull request #2448 from alphagov/add-manual-section-test
added spec file for manual section test
2 parents 063601c + 736402c commit baa39e7

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
require "test_helper"
2+
3+
class ContentItemManualSectionTest < ActiveSupport::TestCase
4+
class DummyContentItem
5+
attr_reader :manual_page_title, :content_item, :manual, :base_path
6+
attr_accessor :details
7+
8+
include ContentItem::ManualSection
9+
def initialize
10+
@content_item = {}
11+
@content_item["title"] = "manualsectiontest"
12+
@manual_page_title = @content_item["title"]
13+
@details = { "section_id" => "ADML1000" }
14+
@manual = { "title" => "harrypotter" }
15+
@base_path = "/a/base/path"
16+
end
17+
end
18+
19+
test "returns title" do
20+
item = DummyContentItem.new
21+
22+
assert_equal("harrypotter", item.title)
23+
end
24+
25+
test "returns page title" do
26+
item = DummyContentItem.new
27+
28+
assert_equal("ADML1000 - manualsectiontest", item.page_title)
29+
end
30+
31+
test "returns document_heading" do
32+
item = DummyContentItem.new
33+
34+
assert_equal(%w[ADML1000 manualsectiontest], item.document_heading)
35+
end
36+
37+
test "returns breadcrumb when section_id is present" do
38+
item = DummyContentItem.new
39+
40+
assert_equal("ADML1000", item.breadcrumb)
41+
end
42+
43+
test "returns breadcrumb when section_id not present" do
44+
item = DummyContentItem.new
45+
46+
item.details = {}
47+
48+
assert_equal("harrypotter", item.breadcrumb)
49+
end
50+
51+
test "returns manual_content_item" do
52+
stub_request(:get, "https://content-store.test.gov.uk/content/a/base/path")
53+
.with(
54+
headers: {
55+
"Accept" => "application/json",
56+
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
57+
"Host" => "content-store.test.gov.uk",
58+
"User-Agent" => "gds-api-adapters/79.1.2 ()",
59+
},
60+
)
61+
.to_return(status: 200, body: "{}", headers: {})
62+
item = DummyContentItem.new
63+
64+
assert_equal({}, item.manual_content_item.parsed_content)
65+
end
66+
end

0 commit comments

Comments
 (0)