Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SD10 committed Mar 24, 2018
1 parent d342bc4 commit caefdbc
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions Tests/Mocks/MockMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@ import Foundation
import CoreLocation
@testable import MessageKit

struct MockLocationItem: LocationItem {

var location: CLLocation
var size: CGSize

init(location: CLLocation) {
self.location = location
self.size = CGSize(width: 240, height: 240)
}

}

struct MockMediaItem: MediaItem {

var url: URL?
var image: UIImage?
var placeholderImage: UIImage
var size: CGSize

init(image: UIImage) {
self.image = image
self.size = CGSize(width: 240, height: 240)
self.placeholderImage = UIImage()
}

}

struct MockMessage: MessageType {

var messageId: String
Expand All @@ -49,16 +76,18 @@ struct MockMessage: MessageType {
}

init(image: UIImage, sender: Sender, messageId: String) {
self.init(data: .photo(image), sender: sender, messageId: messageId)
let mediaItem = MockMediaItem(image: image)
self.init(data: .photo(mediaItem), sender: sender, messageId: messageId)
}

init(thumbnail: UIImage, sender: Sender, messageId: String) {
let url = URL(fileURLWithPath: "")
self.init(data: .video(file: url, thumbnail: thumbnail), sender: sender, messageId: messageId)
let mediaItem = MockMediaItem(image: thumbnail)
self.init(data: .video(mediaItem), sender: sender, messageId: messageId)
}

init(location: CLLocation, sender: Sender, messageId: String) {
self.init(data: .location(location), sender: sender, messageId: messageId)
let locationItem = MockLocationItem(location: location)
self.init(data: .location(locationItem), sender: sender, messageId: messageId)
}

init(emoji: String, sender: Sender, messageId: String) {
Expand Down

0 comments on commit caefdbc

Please sign in to comment.