Skip to content

Instantly share code, notes, and snippets.

View jayesh15111988's full-sized avatar

Jayesh Kawli jayesh15111988

View GitHub Profile
@jayesh15111988
jayesh15111988 / RequestHandlerTests.swift
Created May 3, 2023 16:53
A full source code for tests for network stack on iOS and Swift
// 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
}
@jayesh15111988
jayesh15111988 / NetworkService.swift
Last active November 28, 2023 07:39
A code for demonstrating how to use URLSession to send network request from iOS app
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")!
@jayesh15111988
jayesh15111988 / TestableNetworkServiceExample.swift
Created November 28, 2023 07:45
A sample code to demonstrate how to use protocols to facilitate unit testing in iOS app
//
// TestableNetworkServiceExample.swift
// KayakCodingChallenge
//
// Created by Jayesh Kawli on 11/28/23.
//
import Foundation
import XCTest