2017-06-27 15:56:03 +02:00
//
// J S O N F e e d P a r s e r T e s t s . s w i f t
// R S P a r s e r
//
// C r e a t e d b y B r e n t S i m m o n s o n 6 / 2 6 / 1 7 .
// C o p y r i g h t © 2 0 1 7 R a n c h e r o S o f t w a r e , L L C . A l l r i g h t s r e s e r v e d .
//
import XCTest
import RSParser
class JSONFeedParserTests : XCTestCase {
func testInessentialPerformance ( ) {
// 0 . 0 0 1 s e c o n m y 2 0 1 2 i M a c .
let d = parserData ( " inessential " , " json " , " http://inessential.com/ " )
self . measure {
let _ = try ! FeedParser . parse ( d )
}
}
func testDaringFireballPerformance ( ) {
// 0 . 0 0 9 s e c o n m y 2 0 1 2 i M a c .
let d = parserData ( " DaringFireball " , " json " , " http://daringfireball.net/ " )
self . measure {
let _ = try ! FeedParser . parse ( d )
}
}
2017-11-18 21:41:15 +01:00
func testThatEntitiesAreDecoded ( ) {
let d = parserData ( " DaringFireball " , " json " , " http://daringfireball.net/ " )
let parsedFeed = try ! FeedParser . parse ( d )
// h t t p s : / / g i t h u b . c o m / b r e n t s i m m o n s / E v e r g r e e n / i s s u e s / 1 7 6
// I n t h e a r t i c l e t i t l e d " T h e T a l k S h o w : ‘ I D o L i k e T h r o w i n g a B a b y ’ " ,
// m a k e s u r e t h e c o n t e n t H T M L s t a r t s w i t h " \ n < p > N e w e p i s o d e o f A m e r i c a ’ s "
// i n s t e a d o f " \ n < p > N e w e p i s o d e o f A m e r i c a & # 8 2 1 7 ; s " — t h i s w i l l t e l l u s
// t h a t e n t i t i e s a r e b e i n g d e c o d e d .
for article in parsedFeed ! . items {
if article . title = = " The Talk Show: ‘ I Do Like Throwing a Baby’ " {
XCTAssert ( article . contentHTML ! . hasPrefix ( " \n <p>New episode of America’ s " ) )
return
}
}
XCTAssert ( false , " Expected to find “The Talk Show: ‘ I Do Like Throwing a Baby’ ” article. " )
}
2017-11-25 19:34:48 +01:00
func testGettingFaviconAndIconURLs ( ) {
let d = parserData ( " DaringFireball " , " json " , " http://daringfireball.net/ " )
let parsedFeed = try ! FeedParser . parse ( d ) !
XCTAssert ( parsedFeed . faviconURL = = " https://daringfireball.net/graphics/favicon-64.png " )
XCTAssert ( parsedFeed . iconURL = = " https://daringfireball.net/graphics/apple-touch-icon.png " )
}
2017-11-30 22:19:22 +01:00
func testAllThis ( ) {
let d = parserData ( " allthis " , " json " , " http://leancrew.com/allthis/ " )
let parsedFeed = try ! FeedParser . parse ( d ) !
XCTAssertEqual ( parsedFeed . items . count , 12 )
}
2018-01-08 22:13:15 +01:00
func testCurt ( ) {
let d = parserData ( " curt " , " json " , " http://curtclifton.net/ " )
let parsedFeed = try ! FeedParser . parse ( d ) !
XCTAssertEqual ( parsedFeed . items . count , 26 )
var didFindTwitterQuitterArticle = false
for article in parsedFeed . items {
if article . title = = " Twitter Quitter " {
didFindTwitterQuitterArticle = true
XCTAssertTrue ( article . contentHTML ! . hasPrefix ( " <p>I’ ve decided to close my Twitter account. William Van Hecke <a href= \" https://tinyletter.com/fet/letters/microcosmographia-xlxi-reasons-to-stay-on-twitter \" >makes a convincing case</a> " ) )
}
}
XCTAssertTrue ( didFindTwitterQuitterArticle )
}
2018-02-15 05:56:02 +01:00
func testPixelEnvy ( ) {
let d = parserData ( " pxlnv " , " json " , " http://pxlnv.com/ " )
let parsedFeed = try ! FeedParser . parse ( d ) !
XCTAssertEqual ( parsedFeed . items . count , 20 )
}
2017-06-27 15:56:03 +02:00
}