@@ -23,6 +23,10 @@ class AuthorTests: XCTestCase {
2323 user = testWorld. createUser ( username: " leia " )
2424 postData = try ! testWorld. createPost ( author: user)
2525 }
26+
27+ override func tearDown( ) {
28+ XCTAssertNoThrow ( try testWorld. tryAsHardAsWeCanToShutdownApplication ( ) )
29+ }
2630
2731 // MARK: - Tests
2832
@@ -67,6 +71,65 @@ class AuthorTests: XCTestCase {
6771 XCTAssertEqual ( presenter. authorPosts? . first? . title, postData. post. title)
6872 XCTAssertEqual ( presenter. authorPosts? . first? . contents, postData. post. contents)
6973 }
74+
75+ func testAuthorPageGetsCorrectPageInformation( ) throws {
76+ _ = try testWorld. getResponse ( to: authorsRequestPath)
77+ XCTAssertNil ( presenter. authorPageInformation? . disqusName)
78+ XCTAssertNil ( presenter. authorPageInformation? . googleAnalyticsIdentifier)
79+ XCTAssertNil ( presenter. authorPageInformation? . siteTwitterHandler)
80+ XCTAssertNil ( presenter. authorPageInformation? . loggedInUser)
81+ XCTAssertEqual ( presenter. authorPageInformation? . currentPageURL. absoluteString, authorsRequestPath)
82+ XCTAssertEqual ( presenter. authorPageInformation? . websiteURL. absoluteString, " " )
83+ }
84+
85+ func testAuthorPageInformationGetsLoggedInUser( ) throws {
86+ let user = testWorld. createUser ( )
87+ _ = try testWorld. getResponse ( to: authorsRequestPath, loggedInUser: user)
88+ XCTAssertEqual ( presenter. authorPageInformation? . loggedInUser? . username, user. username)
89+ }
90+
91+ func testSettingEnvVarsWithPageInformation( ) throws {
92+ let googleAnalytics = " ABDJIODJWOIJIWO "
93+ let twitterHandle = " 3483209fheihgifffe "
94+ let disqusName = " 34829u48932fgvfbrtewerg "
95+ setenv ( " BLOG_GOOGLE_ANALYTICS_IDENTIFIER " , googleAnalytics, 1 )
96+ setenv ( " BLOG_SITE_TWITTER_HANDLER " , twitterHandle, 1 )
97+ setenv ( " BLOG_DISQUS_NAME " , disqusName, 1 )
98+ _ = try testWorld. getResponse ( to: authorsRequestPath)
99+ XCTAssertEqual ( presenter. authorPageInformation? . disqusName, disqusName)
100+ XCTAssertEqual ( presenter. authorPageInformation? . googleAnalyticsIdentifier, googleAnalytics)
101+ XCTAssertEqual ( presenter. authorPageInformation? . siteTwitterHandler, twitterHandle)
102+ }
103+
104+ func testCorrectPageInformationForAllAuthors( ) throws {
105+ _ = try testWorld. getResponse ( to: allAuthorsRequestPath)
106+ XCTAssertNil ( presenter. allAuthorsPageInformation? . disqusName)
107+ XCTAssertNil ( presenter. allAuthorsPageInformation? . googleAnalyticsIdentifier)
108+ XCTAssertNil ( presenter. allAuthorsPageInformation? . siteTwitterHandler)
109+ XCTAssertNil ( presenter. allAuthorsPageInformation? . loggedInUser)
110+ XCTAssertEqual ( presenter. allAuthorsPageInformation? . currentPageURL. absoluteString, allAuthorsRequestPath)
111+ XCTAssertEqual ( presenter. allAuthorsPageInformation? . websiteURL. absoluteString, " " )
112+ }
113+
114+ func testPageInformationGetsLoggedInUserForAllAuthors( ) throws {
115+ let user = testWorld. createUser ( )
116+ _ = try testWorld. getResponse ( to: allAuthorsRequestPath, loggedInUser: user)
117+ XCTAssertEqual ( presenter. allAuthorsPageInformation? . loggedInUser? . username, user. username)
118+ }
119+
120+ func testSettingEnvVarsWithPageInformationForAllAuthors( ) throws {
121+ let googleAnalytics = " ABDJIODJWOIJIWO "
122+ let twitterHandle = " 3483209fheihgifffe "
123+ let disqusName = " 34829u48932fgvfbrtewerg "
124+ setenv ( " BLOG_GOOGLE_ANALYTICS_IDENTIFIER " , googleAnalytics, 1 )
125+ setenv ( " BLOG_SITE_TWITTER_HANDLER " , twitterHandle, 1 )
126+ setenv ( " BLOG_DISQUS_NAME " , disqusName, 1 )
127+ _ = try testWorld. getResponse ( to: allAuthorsRequestPath)
128+ XCTAssertEqual ( presenter. allAuthorsPageInformation? . disqusName, disqusName)
129+ XCTAssertEqual ( presenter. allAuthorsPageInformation? . googleAnalyticsIdentifier, googleAnalytics)
130+ XCTAssertEqual ( presenter. allAuthorsPageInformation? . siteTwitterHandler, twitterHandle)
131+ }
132+
70133
71134 // MARK: - Pagination Tests
72135 func testAuthorViewOnlyGetsTheSpecifiedNumberOfPosts( ) throws {
0 commit comments