Skip to content

Commit

Permalink
Remove Test Helpers from Package.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple committed Oct 5, 2023
1 parent 3e9c9e9 commit 916db7c
Show file tree
Hide file tree
Showing 110 changed files with 302 additions and 528 deletions.
21 changes: 6 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ let package = Package(
targets: ["StreamChatTestMockServer"]
),
],
dependencies: [
.package(name: "StreamChatTestHelpers", url: "https://github.com/GetStream/stream-chat-swift-test-helpers.git", .exact("0.2.11")),
.package(name: "Swifter", url: "https://github.com/httpswift/swifter", .exact("1.5.0"))
],
targets: [
.target(
name: "StreamChat",
Expand All @@ -43,21 +39,16 @@ let package = Package(
exclude: ["Info.plist", "Generated/L10n_template.stencil"],
resources: [.process("Resources")]
),
.target(name: "StreamChatTestTools",
dependencies: [
.target(name: "StreamChat"),
.product(name: "StreamChatTestHelpers", package: "StreamChatTestHelpers"),
],
.target(
name: "StreamChatTestTools",
dependencies: ["StreamChat"],
path: "TestTools/StreamChatTestTools",
exclude: ["Info.plist"],
resources: [.process("Fixtures")]
),
.target(name: "StreamChatTestMockServer",
dependencies: [
.target(name: "StreamChat"),
.product(name: "StreamChatTestHelpers", package: "StreamChatTestHelpers"),
.product(name: "Swifter", package: "Swifter")
],
.target(
name: "StreamChatTestMockServer",
dependencies: ["StreamChat"],
path: "TestTools/StreamChatTestMockServer",
exclude: ["Info.plist"],
resources: [.process("Fixtures")]
Expand Down
245 changes: 96 additions & 149 deletions StreamChat.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion StreamChatUITestsAppUITests/StreamChatUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright © 2023 Stream.io Inc. All rights reserved.
//

@_exported import StreamChatTestHelpers
@_exported import StreamChatTestMockServer
@_exported import StreamSwiftTestHelpers
import Foundation

final class StreamChatUITests {}
26 changes: 26 additions & 0 deletions TestTools/StreamChatTestMockServer/Extensions/Dictionary.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright © 2022 Stream.io Inc. All rights reserved.
//

import Foundation

public extension Dictionary {

func jsonToString(prettyPrinted: Bool = false) -> String {
var options: JSONSerialization.WritingOptions = []
if prettyPrinted {
options = JSONSerialization.WritingOptions.prettyPrinted
}

do {
let data = try JSONSerialization.data(withJSONObject: self, options: options)
if let string = String(data: data, encoding: String.Encoding.utf8) {
return string
}
} catch {
print(error)
}

return ""
}
}
35 changes: 35 additions & 0 deletions TestTools/StreamChatTestMockServer/Extensions/String.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright © 2022 Stream.io Inc. All rights reserved.
//

import XCTest

public extension String {

var json: [String: Any] {
try! JSONSerialization.jsonObject(with: Data(self.utf8),
options: .mutableContainers) as! [String: Any]
}

func replace(_ target: String, to: String) -> String {
replacingOccurrences(of: target,
with: to,
options: NSString.CompareOptions.literal,
range: nil)
}

var html: Self {
self.isEmpty ? "" : "<p>\(self)</p>\n"
}

}

public extension Substring {
func capitalizingFirstLetter() -> Substring {
prefix(1).capitalized + dropFirst()
}

mutating func capitalizeFirstLetter() {
self = self.capitalizingFirstLetter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@testable import StreamChat
import Foundation
import Swifter
import StreamChatTestHelpers

public extension StreamMockServer {

Expand Down
16 changes: 15 additions & 1 deletion TestTools/StreamChatTestMockServer/Utilities/TestData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@testable import StreamChat
import Swifter
import XCTest
import StreamChatTestHelpers

public enum TestData {

Expand Down Expand Up @@ -50,5 +49,20 @@ public enum TestData {
case sad
case like
}
}

extension XCTestCase {
/// Loads a data from a file.
/// - Parameters:
/// - name: a file name.
/// - extension: a file extension. JSON by default.
/// - Returns: a file data.
public static func mockData(fromFile name: String, bundle: Bundle, extension: String = "json") -> Data {
guard let url = bundle.url(forResource: name, withExtension: `extension`) else {
XCTFail("\n❌ Mock file \"\(name).json\" not found in bundle \(bundle.bundleURL.lastPathComponent)")
return .init()
}

return try! Data(contentsOf: url)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Foundation
@testable import StreamChat
import StreamChatTestHelpers
@testable import StreamSwiftTestHelpers

public class ChatChannelListController_Mock: ChatChannelListController, Spy {
public var recordedFunctions: [String] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//

import Foundation
import StreamChatTestHelpers
@testable import StreamChat
@testable import StreamSwiftTestHelpers

class AuthenticationRepository_Mock: AuthenticationRepository, Spy {
enum Signature {
Expand Down
2 changes: 1 addition & 1 deletion TestTools/StreamChatTestTools/StreamChatTestTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

import Foundation
@_exported import StreamChatTestHelpers
@_exported import StreamSwiftTestHelpers
import XCTest

extension Bundle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Foundation
@testable import StreamChat
import StreamChatTestHelpers
@testable import StreamSwiftTestHelpers
import XCTest

final class CreateCallPayload_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Foundation
@testable import StreamChat
import StreamChatTestHelpers
@testable import StreamSwiftTestHelpers
import XCTest

final class CallRequestBody_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Foundation
@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class AudioAnalysisEngine_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import AVFoundation
import Foundation
@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class StreamAssetPropertyLoader_Tests: XCTestCase {
Expand Down
2 changes: 1 addition & 1 deletion Tests/StreamChatTests/Audio/StreamAudioPlayer_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import AVFoundation
import Foundation
@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class StreamAudioPlayer_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import AVFoundation
@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class StreamAudioQueuePlayer_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import AVFoundation
import Foundation
@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class StreamAudioRecorder_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import AVFoundation
@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class StreamAudioSessionConfigurator_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import AVFoundation
@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class StreamAudioWaveformAnalyser_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class AnyAttachmentPayload_Tests: XCTestCase {
Expand Down
2 changes: 1 addition & 1 deletion Tests/StreamChatTests/StreamChatTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

import Foundation

@_exported import StreamChatTestHelpers
@_exported import StreamSwiftTestHelpers

final class StreamChatTests {}
4 changes: 2 additions & 2 deletions Tests/StreamChatTests/Utils/CooldownTracker_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//

@testable import StreamChat
import StreamChatTestHelpers
import StreamChatTestTools
@testable import StreamChatTestTools
@testable import StreamSwiftTestHelpers
import XCTest

final class CooldownTracker_Tests: XCTestCase {
Expand Down
4 changes: 2 additions & 2 deletions Tests/StreamChatTests/Utils/Debouncer_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import Foundation
@testable import StreamChat
import StreamChatTestHelpers
import StreamChatTestTools
@testable import StreamChatTestTools
@testable import StreamSwiftTestHelpers
import XCTest

final class Debouncer_Tests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

@testable import StreamChat
import StreamChatTestTools
@testable import StreamChatTestTools
import XCTest

final class LazyCachedMapCollection_Tests: XCTestCase {
Expand Down
2 changes: 1 addition & 1 deletion Tests/StreamChatTests/Utils/MulticastDelegate_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

@testable import StreamChat
import StreamChatTestHelpers
@testable import StreamSwiftTestHelpers
import XCTest

final class MulticastDelegate_Tests: XCTestCase {
Expand Down
Loading

0 comments on commit 916db7c

Please sign in to comment.