This repository has been archived by the owner on Nov 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from bkobilansky/sharing-provider-tests
Sharing provider tests
- Loading branch information
Showing
3 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// SharingProviderTests.swift | ||
// Example | ||
// | ||
// Created by Brandon Kobilansky on 1/26/16. | ||
// Copyright © 2016 FolioReader. All rights reserved. | ||
// | ||
|
||
@testable import FolioReaderKit | ||
|
||
import Quick | ||
import Nimble | ||
|
||
class SharingProviderTests: QuickSpec { | ||
override func spec() { | ||
var subject: FolioReaderSharingProvider! | ||
|
||
context("when sharing a document") { | ||
let activityViewController = UIActivityViewController(activityItems: [], applicationActivities: nil) | ||
|
||
it("sets the subject field") { | ||
subject = self.providerWithHTML() | ||
let subjectForActivityType = subject.activityViewController(activityViewController, subjectForActivityType: nil) | ||
expect(subjectForActivityType).to(equal(subject.subject)) | ||
} | ||
|
||
context("without HTML") { | ||
beforeEach { | ||
subject = self.providerWithoutHTML() | ||
} | ||
|
||
it("returns text for a mail activity") { | ||
let itemForActivityType = subject.activityViewController(activityViewController, itemForActivityType: UIActivityTypeMail) as? String | ||
expect(itemForActivityType).to(equal(subject.text)) | ||
} | ||
} | ||
|
||
context("with HTML") { | ||
beforeEach { | ||
subject = self.providerWithHTML() | ||
} | ||
|
||
it("returns HTML for a mail activity") { | ||
let itemForActivityType = subject.activityViewController(activityViewController, itemForActivityType: UIActivityTypeMail) as? String | ||
expect(itemForActivityType).to(equal(subject.html)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func providerWithHTML() -> FolioReaderSharingProvider { | ||
return FolioReaderSharingProvider(subject: "a subject", text: "some text", html: "<html><body>foo</body></html>") | ||
} | ||
|
||
func providerWithoutHTML() -> FolioReaderSharingProvider { | ||
return FolioReaderSharingProvider(subject: "a subject", text: "some text", html: nil) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters