NetNewsWire/Tests/NetNewsWireTests/SharingTests.swift

66 lines
2.0 KiB
Swift
Raw Normal View History

2019-08-23 13:23:30 +02:00
//
// SharingTests.swift
// NetNewsWireTests
//
// Created by Mathijs Bernson on 23/08/2019.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import Articles
2019-08-23 13:23:30 +02:00
import XCTest
2019-08-23 13:23:30 +02:00
@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()
2020-07-10 22:51:58 +02:00
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())
)
2019-08-23 13:23:30 +02:00
}
private func randomId() -> String {
return UUID().uuidString
}
}