Skip to content

Commit

Permalink
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.
Browse files Browse the repository at this point in the history
^ This is the 1st commit message:

[#13] Add backend reset password

^ The commit message #2 will be skipped:

^ [#11] Add notification manger
blyscuit committed Nov 30, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 52f8b48 commit 5db65c0
Showing 7 changed files with 125 additions and 0 deletions.
14 changes: 14 additions & 0 deletions iosApp/Survey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
09495F82290109760036BDFB /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495F81290109730036BDFB /* NotificationManager.swift */; };
09495F84290110640036BDFB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495F83290110630036BDFB /* AppDelegate.swift */; };
09495F88290114230036BDFB /* NotificationManagerSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495F86290113DC0036BDFB /* NotificationManagerSpec.swift */; };
09495FB9290B98580036BDFB /* Shared+AutoMockable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495FB8290B98580036BDFB /* Shared+AutoMockable.swift */; };
09495FC4290BA3D80036BDFB /* XCTestCase+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495FC2290BA3AF0036BDFB /* XCTestCase+Publisher.swift */; };
09495FC7290BA49D0036BDFB /* Combine+Collect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495FC6290BA49D0036BDFB /* Combine+Collect.swift */; };
09495FC9291106A00036BDFB /* Constants+SystemImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495FC8291106A00036BDFB /* Constants+SystemImage.swift */; };
09495FCB291107760036BDFB /* Image+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495FCA291107760036BDFB /* Image+Constants.swift */; };
09495FCD291109450036BDFB /* CGFloat+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495FCC291109450036BDFB /* CGFloat+Extensions.swift */; };
@@ -62,6 +65,7 @@
0982A80729278E9000FC1976 /* SurveyHeaderLoading.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982A80129278E9000FC1976 /* SurveyHeaderLoading.swift */; };
0982A80829278EC200FC1976 /* LoginFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982A7EE29223DA600FC1976 /* LoginFlow.swift */; };
0982A809292B6BCA00FC1976 /* ViewId+Splash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495F6728FF97490036BDFB /* ViewId+Splash.swift */; };
0982A87E292F841D00FC1976 /* Shared+AutoMockable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09495FB8290B98580036BDFB /* Shared+AutoMockable.swift */; };
0982A880292F847900FC1976 /* ResetPassword+DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982A87F292F847900FC1976 /* ResetPassword+DataSource.swift */; };
09CE770C28E191B400EAA9EE /* AppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE770B28E191B400EAA9EE /* AppCoordinator.swift */; };
09CE770F28E1922000EAA9EE /* Screen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE770E28E1922000EAA9EE /* Screen.swift */; };
@@ -154,6 +158,9 @@
09495F81290109730036BDFB /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; };
09495F83290110630036BDFB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
09495F86290113DC0036BDFB /* NotificationManagerSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManagerSpec.swift; sourceTree = "<group>"; };
09495FB8290B98580036BDFB /* Shared+AutoMockable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Shared+AutoMockable.swift"; sourceTree = "<group>"; };
09495FC2290BA3AF0036BDFB /* XCTestCase+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTestCase+Publisher.swift"; sourceTree = "<group>"; };
09495FC6290BA49D0036BDFB /* Combine+Collect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Combine+Collect.swift"; sourceTree = "<group>"; };
09495FC8291106A00036BDFB /* Constants+SystemImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Constants+SystemImage.swift"; sourceTree = "<group>"; };
09495FCA291107760036BDFB /* Image+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Image+Constants.swift"; sourceTree = "<group>"; };
09495FCC291109450036BDFB /* CGFloat+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGFloat+Extensions.swift"; sourceTree = "<group>"; };
@@ -323,6 +330,7 @@
09495FB7290B981B0036BDFB /* AutoMockable */ = {
isa = PBXGroup;
children = (
09495FB8290B98580036BDFB /* Shared+AutoMockable.swift */,
);
path = AutoMockable;
sourceTree = "<group>";
@@ -362,13 +370,15 @@
09495FC1290BA3900036BDFB /* XCTest */ = {
isa = PBXGroup;
children = (
09495FC2290BA3AF0036BDFB /* XCTestCase+Publisher.swift */,
);
path = XCTest;
sourceTree = "<group>";
};
09495FC5290BA46E0036BDFB /* Combine */ = {
isa = PBXGroup;
children = (
09495FC6290BA49D0036BDFB /* Combine+Collect.swift */,
);
path = Combine;
sourceTree = "<group>";
@@ -1430,6 +1440,7 @@
0982A7E429222F2000FC1976 /* LoginView.swift in Sources */,
EABA6D4F0FE97293430D3FC9 /* Constants.swift in Sources */,
09495FCD291109450036BDFB /* CGFloat+Extensions.swift in Sources */,
09495FB9290B98580036BDFB /* Shared+AutoMockable.swift in Sources */,
09CE773328E2ED2300EAA9EE /* KoinApplication.swift in Sources */,
0982A7E329222EFF00FC1976 /* RouteCoordinator.swift in Sources */,
09495F7828FFF2D50036BDFB /* ViewId+SurveySelection.swift in Sources */,
@@ -1446,6 +1457,7 @@
09CE771528E1AB0B00EAA9EE /* ViewId+ResetPassword.swift in Sources */,
09636B0B28D48CFD00A5CB97 /* Typealiases.swift in Sources */,
0982A7F6292371F000FC1976 /* StringResource+Localized.swift in Sources */,
09495FC7290BA49D0036BDFB /* Combine+Collect.swift in Sources */,
09636B0028D4860F00A5CB97 /* PrimaryTextField.swift in Sources */,
09495F6628FF97080036BDFB /* SplashView.swift in Sources */,
09495F82290109760036BDFB /* NotificationManager.swift in Sources */,
@@ -1489,7 +1501,9 @@
files = (
5BBBFAF49689F25A8C1D57AB /* AutoMockable.generated.swift in Sources */,
09495F88290114230036BDFB /* NotificationManagerSpec.swift in Sources */,
09495FC4290BA3D80036BDFB /* XCTestCase+Publisher.swift in Sources */,
3D0ADA9FBBF8D55D5F00610F /* OptionalUnwrapSpec.swift in Sources */,
0982A87E292F841D00FC1976 /* Shared+AutoMockable.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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
}
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()
}
}
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()
}
}
1 change: 1 addition & 0 deletions iosApp/tools/sourcery/templates/AutoMockable.stencil
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)
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) } )
}
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@ class ResetPasswordViewModelTest : TestsWithMocks() {
@Mock
lateinit var resetPasswordUseCase: ResetPasswordUseCase

@Mock
lateinit var resetPasswordUseCase: ResetPasswordUseCase

private val email = "email@mail.com"
private val mainThreadSurrogate = newSingleThreadContext("UI thread")

0 comments on commit 5db65c0

Please sign in to comment.