-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
^ This is a combination of 2 commits.
^ This is the 1st commit message: [#13] Add backend reset password ^ The commit message #2 will be skipped: ^ [#11] Add notification manger
Showing
7 changed files
with
125 additions
and
0 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
21 changes: 21 additions & 0 deletions
21
iosApp/Survey/Sources/Supports/Helpers/KMM/AutoMockable/Shared+AutoMockable.swift
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,21 @@ | ||
// swiftlint:disable:this file_name | ||
// | ||
// Shared+AutoMockable.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 28/10/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import Shared | ||
|
||
// sourcery: AutoMockable | ||
protocol ResetPasswordUseCaseKMM: ResetPasswordUseCase { | ||
|
||
func invoke(email: String) -> Kotlinx_coroutines_coreFlow | ||
func invokeNative(email: String) | ||
-> ( | ||
@escaping (String, KotlinUnit) -> KotlinUnit, | ||
@escaping (Error?, KotlinUnit) -> KotlinUnit | ||
) -> () -> KotlinUnit | ||
} |
22 changes: 22 additions & 0 deletions
22
iosApp/SurveyTests/Sources/Utilities/Extensions/Combine/Combine+Collect.swift
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,22 @@ | ||
// swiftlint:disable:this file_name | ||
// | ||
// Combine+Collect.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 28/10/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
// From https://www.swiftbysundell.com/articles/unit-testing-combine-based-swift-code/ | ||
|
||
extension Published.Publisher { | ||
|
||
func collectNext(_ count: Int) -> AnyPublisher<[Output], Never> { | ||
dropFirst() | ||
.collect(count) | ||
.first() | ||
.eraseToAnyPublisher() | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
iosApp/SurveyTests/Sources/Utilities/Extensions/XCTest/XCTestCase+Publisher.swift
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,52 @@ | ||
// | ||
// XCTestCase+Publisher.swift | ||
// Survey | ||
// | ||
// Created by Bliss on 28/10/22. | ||
// Copyright © 2022 Nimble. All rights reserved. | ||
// | ||
|
||
import Combine | ||
import XCTest | ||
|
||
// From https://www.swiftbysundell.com/articles/unit-testing-combine-based-swift-code/ | ||
|
||
extension XCTestCase { | ||
|
||
@discardableResult | ||
func awaitPublisher<T: Publisher>( | ||
_ publisher: T, | ||
timeout: TimeInterval = 10, | ||
file: StaticString = #file, | ||
line: UInt = #line | ||
) throws -> T.Output { | ||
var result: Result<T.Output, Error>? | ||
let expectation = self.expectation(description: "Awaiting publisher") | ||
|
||
let cancellable = publisher.sink( | ||
receiveCompletion: { completion in | ||
switch completion { | ||
case let .failure(error): | ||
result = .failure(error) | ||
case .finished: | ||
break | ||
} | ||
|
||
expectation.fulfill() | ||
}, | ||
receiveValue: { value in | ||
result = .success(value) | ||
} | ||
) | ||
waitForExpectations(timeout: timeout) | ||
cancellable.cancel() | ||
let unwrappedResult = try XCTUnwrap( | ||
result, | ||
"Awaited publisher did not produce any output", | ||
file: file, | ||
line: line | ||
) | ||
|
||
return try unwrappedResult.get() | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import Foundation | ||
import Shared | ||
#if os(iOS) || os(tvOS) || os(watchOS) | ||
import UIKit | ||
#elseif os(OSX) | ||
|
12 changes: 12 additions & 0 deletions
12
shared/src/commonMain/kotlin/co/nimblehq/blisskmmic/helpers/extensions/ios/Flow+AnyFlow.kt
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,12 @@ | ||
@file:Suppress("MatchingDeclarationName") | ||
package co.nimblehq.blisskmmic.helpers.extensions.ios | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
|
||
// For iOS Unit Test | ||
class AnyFlow<T>(source: Flow<T>): Flow<T> by source { | ||
|
||
constructor(result: T) : this( flow { emit(result) } ) | ||
constructor(errorMessage: String) : this( flow { error(errorMessage) } ) | ||
} |
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