NetNewsWire/Tests/NetNewsWireTests/SharingTests.swift
Fábio Oliveira d05594dafb Fix Unit Tests
- Adopt new fields from SecretsProvider in FeedlyTestSecrets
-Fix call to Account init that was expecting an optional
- Linked `Articles` and `RSCore` libraries to the Unit Tests target
- Small change to order of imports for consistency
2021-02-24 01:13:47 +01:00

66 lines
2.0 KiB
Swift

//
// SharingTests.swift
// NetNewsWireTests
//
// Created by Mathijs Bernson on 23/08/2019.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import Articles
import XCTest
@testable import NetNewsWire
class SharingTests: XCTestCase {
func testSharingSubject() {
let sharingServiceDelegate = SharingServiceDelegate(nil)
let sharingService = NSSharingService(title: "Chirpy", image: NSImage(size: NSSize.zero), alternateImage: nil, handler: {})
sharingService.delegate = sharingServiceDelegate
sharingService.perform(withItems: [
ArticlePasteboardWriter(article: article(titled: "Immunization")),
])
XCTAssertEqual("Immunization", sharingService.subject)
}
func testSharingSubjectMultipleArticles() {
let sharingServiceDelegate = SharingServiceDelegate(nil)
let sharingService = NSSharingService(title: "Chirpy", image: NSImage(size: NSSize.zero), alternateImage: nil, handler: {})
sharingService.delegate = sharingServiceDelegate
sharingService.perform(withItems: [
ArticlePasteboardWriter(article: article(titled: "NetNewsWire Status: Almost Beta")),
ArticlePasteboardWriter(article: article(titled: "No Algorithms Follow-Up")),
])
XCTAssertEqual("NetNewsWire Status: Almost Beta, No Algorithms Follow-Up", sharingService.subject)
}
private func article(titled title: String) -> Article {
let articleId = randomId()
return Article(accountID: randomId(),
articleID: articleId,
webFeedID: randomId(),
uniqueID: randomId(),
title: title,
contentHTML: nil,
contentText: nil,
url: nil,
externalURL: nil,
summary: nil,
imageURL: nil,
datePublished: nil,
dateModified: nil,
authors: nil,
status: ArticleStatus(articleID: articleId, read: true, dateArrived: Date())
)
}
private func randomId() -> String {
return UUID().uuidString
}
}