-
Notifications
You must be signed in to change notification settings - Fork 532
/
SharingTests.swift
65 lines (53 loc) · 2 KB
/
SharingTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// 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,
feedID: 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
}
}