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
// | |
// TestableNetworkServiceExample.swift | |
// KayakCodingChallenge | |
// | |
// Created by Jayesh Kawli on 11/28/23. | |
// | |
import Foundation | |
import XCTest |
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
struct Name: Decodable { | |
let firstName: String | |
let lastName: String | |
} | |
final class NetworkService { | |
func loadSampleData(completion: @escaping (Result<Name, Error>) -> Void) { | |
let url = URL(string: "www.google.com")! |
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
// JSONDataReader.swift | |
import XCTest | |
final class JSONDataReader { | |
static func getDataFromJSONFile(with name: String) -> Data? { | |
guard let pathString = Bundle(for: self).path(forResource: name, ofType: "json") else { | |
XCTFail("Mock JSON file \(name).json not found") | |
return nil | |
} |
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
// An utility view extension | |
extension View { | |
@ViewBuilder | |
func `if`<Transform: View>(_ condition: Bool, transform: (Self) -> Transform) -> some View { | |
if condition { transform(self) } | |
else { self } | |
} | |
} |
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
// A protocol for mocking DispatchQueue instance | |
protocol DispatchQueueType { | |
func async(execute work: @escaping @convention(block) () -> Void) | |
} | |
// Confirming existing DispatchQueue to DispatchQueueType | |
extension DispatchQueue: DispatchQueueType { | |
func async(execute work: @escaping @convention(block) () -> Void) { | |
async(group: nil, qos: .unspecified, flags: [], execute: work) |
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
import SwiftUI | |
struct CustomViewDidLoad: View { | |
var body: some View { | |
VStack { | |
Text("Hello") | |
} | |
} |
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
import Foundation | |
enum APIRouteDomain { | |
case userLoginManagement(APIRoute) | |
case accountInfoManagement(APIRoute) | |
case accountManagement(APIRoute) | |
var associatedApiRoute: APIRoute { | |
switch self { | |
case .userLoginManagement(let apiRoute), .accountInfoManagement(let apiRoute), .accountManagement(let apiRoute): |
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
// | |
// InfiniteLoadingScreen.swift | |
// Test | |
// | |
// Created by Jayesh Kawli on 1/12/23. | |
// | |
import SwiftUI | |
struct Employee: Identifiable, Equatable { |
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
class VerticalScrollView : UIViewController { | |
init() { | |
super.init(nibName: nil, bundle: nil) | |
} | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} |
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
// | |
// HorizontalScrollView.swift | |
// Test | |
// | |
// Created by Jayesh Kawli on 4/21/23. | |
// | |
import UIKit | |
class HorizontalScrollView : UIViewController { |
NewerOlder