Permalink
Browse files

refactored view model data

  • Loading branch information...
NatashaTheRobot committed Mar 23, 2017
1 parent 181c373 commit 03273badffb83c39a5d21dce4bd31b9094c8f81e
@@ -0,0 +1,143 @@
//
// SessionTests.swift
// TrySwiftData
//
// Created by Natasha Murashev on 3/18/17.
// Copyright © 2017 CocoaPods. All rights reserved.
//
import XCTest
import TrySwiftData
/**
class SessionTests: XCTestCase {
fileprivate let workshop = nyc2016Sessions["freeswiftworkshop"]!
fileprivate let workshopNoEvent = tko2017Sessions["day3APIWorkshop"]!
fileprivate let meetup = nyc2016Sessions["preconfmeetup"]!
fileprivate let talk = nyc2016Sessions["day2Lambda"]!
fileprivate let lightningTalk = tko2017Sessions["day1LightningTalk1"]!
fileprivate let officeHours = tko2017Sessions["day1FelixOfficeHours"]!
fileprivate let announcement = tko2017Sessions["day1Opening"]!
fileprivate let sponsoredDemo = nyc2016Sessions["day3SponsoredDemo"]!
fileprivate let breakfast = nyc2016Sessions["day2Breakfast"]!
fileprivate let coffeeBreakSponsored = nyc2016Sessions["day2FirstCoffee"]!
fileprivate let coffeeBreak = tko2017Sessions["day1FirstCoffee"]!
fileprivate let lunch = tko2017Sessions["day1Lunch"]!
fileprivate let party = nyc2016Sessions["day2Party"]!
}
// MARK: Session Formatted Title Tests
extension SessionTests {
func testFormattedTitle_Workshop() {
XCTAssertEqual(workshop.formattedTitle, "FREE Swift Workshop")
}
func testFormattedTitle_WorkshopNoEvent() {
XCTAssertEqual(workshopNoEvent.formattedTitle, "API Workshops")
}
func testFormattedTitle_Meetup() {
XCTAssertEqual(meetup.formattedTitle, "Pre-conference Meetup")
}
func testFormattedTitle_Breakfast() {
XCTAssertEqual(breakfast.formattedTitle, "Breakfast & Registration")
}
func testFormattedTitle_Announcement() {
XCTAssertEqual(announcement.formattedTitle, "Opening Remarks")
}
func testFormattedTitle_Talk() {
XCTAssertEqual(talk.formattedTitle, "Lambda: There and Back Again")
}
func testFormattedTitle_LightningTalk() {
XCTAssertEqual(lightningTalk.formattedTitle, "The Safety of Unsafe Swift")
}
func testFormattedTitle_SponsoredDemo() {
XCTAssertEqual(sponsoredDemo.formattedTitle, "Sponsored Demo")
}
func testFormattedTitle_CoffeeBreak() {
XCTAssertEqual(coffeeBreakSponsored.formattedTitle, "Coffee Break, by Domo")
XCTAssertEqual(coffeeBreak.formattedTitle, "Coffee Break")
}
func testFormattedTitle_Lunch() {
XCTAssertEqual(lunch.formattedTitle, "Lunch")
}
func testFormattedTitle_OfficeHours() {
XCTAssertEqual(officeHours.formattedTitle, "Office Hours with Felix Krause")
}
func testFormattedTitle_OfficeHoursNoSpeaker() {
let officeHoursNoSpeaker = officeHours
officeHoursNoSpeaker.presentation?.speaker = nil
XCTAssertEqual(officeHoursNoSpeaker.formattedTitle, "Office Hours")
}
func testFormattedTitle_Party() {
XCTAssertEqual(party.formattedTitle, "🍕 & 🎸 Party with Airplane Mode")
}
}
// MARK: Session Formatted Subtitle Tests
private extension SessionTests {
func testFormattedSubtitle_Workshop() {
}
func testFormattedSubtitle_Meetup() {
}
func testFormattedSubtitle_Breakfast() {
}
func testFormattedSubtitle_Announcement() {
}
func testFormattedSubtitle_Talk() {
}
func testFormattedSubtitle_LightningTalk() {
}
func testFormattedSubtitle_SponsoredDemo() {
}
func testFormattedSubtitle_CoffeeBreak() {
}
func testFormattedSubtitle_Lunch() {
}
func testFormattedSubtitle_OfficeHours() {
}
func testFormattedSubtitle_Party() {
}
}
*/
@@ -31,6 +31,7 @@
22FE792F1E56AF3700DCFCAF /* TKO2017Organizers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22FE792E1E56AF3700DCFCAF /* TKO2017Organizers.swift */; };
607FACEC1AFB9204008FA782 /* CreateRealmTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* CreateRealmTests.swift */; };
D1C2A1C1C1ED581F9395D1C3 /* Pods_TrySwiftData_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2E3D343B3BCFD0FE16F48FBA /* Pods_TrySwiftData_Tests.framework */; };
FA0C4AA31E7D06CB00F72B7A /* SessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA0C4AA21E7D06CB00F72B7A /* SessionTests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -62,6 +63,7 @@
607FACEB1AFB9204008FA782 /* CreateRealmTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateRealmTests.swift; sourceTree = "<group>"; };
CE171203CD5CC3EE87F100D4 /* Pods-TrySwiftData_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrySwiftData_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TrySwiftData_Tests/Pods-TrySwiftData_Tests.release.xcconfig"; sourceTree = "<group>"; };
F34162B8E33CF2073A2BD225 /* Pods-TrySwiftData_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrySwiftData_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TrySwiftData_Tests/Pods-TrySwiftData_Tests.debug.xcconfig"; sourceTree = "<group>"; };
FA0C4AA21E7D06CB00F72B7A /* SessionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -134,6 +136,7 @@
isa = PBXGroup;
children = (
607FACEB1AFB9204008FA782 /* CreateRealmTests.swift */,
FA0C4AA21E7D06CB00F72B7A /* SessionTests.swift */,
22F0E33F1E50F1B50060EA9F /* NYC-2016 */,
22F0E34B1E50F1B50060EA9F /* TKO-2017 */,
607FACE91AFB9204008FA782 /* Supporting Files */,
@@ -298,6 +301,7 @@
22F0E3631E50F1B50060EA9F /* TKO2017ConferenceDays.swift in Sources */,
22F0E36B1E50F1B50060EA9F /* TKO2017Speakers.swift in Sources */,
22F0E3681E50F1B50060EA9F /* TKO2017Presentations.swift in Sources */,
FA0C4AA31E7D06CB00F72B7A /* SessionTests.swift in Sources */,
22F0E35C1E50F1B50060EA9F /* NYC2016Locations.swift in Sources */,
226E7B321E56D9BF0018E2F9 /* NYC2016Organizers.swift in Sources */,
22F0E35A1E50F1B50060EA9F /* NYC2016Events.swift in Sources */,

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,54 @@
//
// AnnouncementSessionViewModel.swift
// Pods
//
// Created by Natasha Murashev on 3/23/17.
//
//
struct AnnouncementSessionViewModel: SessionDisplayable {
private let session: Session
private let defaults: SessionDefaults
init?(session: Session) {
if session.type == .announcement {
self.session = session
self.defaults = SessionDefaults(session: session)
} else {
return nil
}
}
var title: String {
return defaults.title
}
var subtitle: String {
return defaults.subtitle
}
var logoURL: URL {
return defaults.imageURL ?? defaults.logoImageURL
}
var location: String {
return defaults.location
}
var sessionDescription: String {
return "📣".localized()
}
var presentationSummary: String {
return defaults.summary
}
var selectable: Bool {
return false
}
var twitter: String {
return "@\(defaults.twitter)"
}
}
Binary file not shown.
@@ -0,0 +1,56 @@
//
// BreakfastSession.swift
// Pods
//
// Created by Natasha Murashev on 3/23/17.
//
//
struct BreakfastSessionViewModel: SessionDisplayable {
private let session: Session
private let defaults: SessionDefaults
init?(session: Session) {
if session.type == .breakfast {
self.session = session
self.defaults = SessionDefaults(session: session)
} else {
return nil
}
}
var title: String {
return defaults.title
}
var subtitle: String {
return defaults.subtitle
}
var logoURL: URL {
return defaults.imageURL ?? defaults.logoImageURL
}
var location: String {
return defaults.location
}
var sessionDescription: String {
return "❤️".localized()
}
var presentationSummary: String {
return defaults.summary
}
var selectable: Bool {
return false
}
var twitter: String {
return "@\(defaults.twitter)"
}
}
@@ -0,0 +1,69 @@
//
// CoffeeBreakSessionViewModel.swift
// Pods
//
// Created by Natasha Murashev on 3/23/17.
//
//
struct CoffeeBreakSessionViewModel: SessionDisplayable {
private let session: Session
private let defaults: SessionDefaults
init?(session: Session) {
if session.type == .coffeeBreak {
self.session = session
self.defaults = SessionDefaults(session: session)
} else {
return nil
}
}
var title: String {
if let sponsor = session.sponsor {
return String(format: "Coffee Break, by %@".localized(), sponsor.name)
}
return "Coffee Break".localized()
}
var subtitle: String {
if let sponsor = session.sponsor {
return sponsor.localizedName
}
return defaults.subtitle
}
var logoURL: URL {
if let imageURL = defaults.imageURL {
return imageURL
}
if let sponsor = session.sponsor {
return sponsor.logoURL
}
return defaults.logoImageURL
}
var location: String {
return defaults.location
}
var sessionDescription: String {
return "❤️".localized()
}
var presentationSummary: String {
return defaults.summary
}
var selectable: Bool {
return session.sponsor != nil
}
var twitter: String {
let twitter = session.sponsor?.twitter ?? defaults.twitter
return "@\(twitter)"
}
}
Oops, something went wrong.

0 comments on commit 03273ba

Please sign in to comment.