Skip to content

Commit

Permalink
Merge pull request #2 from rokon-uddin/refator
Browse files Browse the repository at this point in the history
fix: don't get name of App in unit tests
  • Loading branch information
rokon-uddin authored Jul 10, 2024
2 parents f0d3843 + 184afca commit ab76f2e
Show file tree
Hide file tree
Showing 49 changed files with 135 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// FeatureReducer.swift
// Common
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.app_name}}/Common/Sources/Common/Heap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Heap.swift
// Common
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// AppError.swift
// Domain
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Product.swift
// Domain
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Repository.swift
// Domain
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// UseCase.swift
// Domain
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// PrepareCoreDataUseCase.swift
// Domain
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ProductUseCase.swift
// Domain
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SaveProductUseCase.swift
// Domain
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
6 changes: 3 additions & 3 deletions {{cookiecutter.app_name}}/Features/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ let package = Package(
platforms: [.macOS(.v12), .iOS(.v16)],
products: [
.library(
name: "App",
targets: ["App"]
name: "Product",
targets: ["Product"]
),

.library(
Expand All @@ -28,7 +28,7 @@ let package = Package(
],
targets: [
.target(
name: "App",
name: "Product",
dependencies: [
"Counter",
.product(name: "Common", package: "Common"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CounterFeature.swift
// Features
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// CounterView.swift
// Features
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// AppClient.swift
// ProductClient.swift
// Features
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand All @@ -12,7 +12,7 @@ import Foundation
import NetworkPlatform
import PersistentPlatform

struct AppClient {
struct ProductClient {
var getProduct: any ProductUseCaseType
var saveProduct: any SaveProductUseCaseType
var prepareCoreData: any PrepareCoreDataUseCaseType
Expand All @@ -29,24 +29,24 @@ struct AppClient {
}

extension DependencyValues {
var appClient: AppClient {
get { self[AppClient.self] }
set { self[AppClient.self] = newValue }
var appClient: ProductClient {
get { self[ProductClient.self] }
set { self[ProductClient.self] = newValue }
}
}

extension AppClient: DependencyKey {
public static var liveValue = AppClient(
extension ProductClient: DependencyKey {
public static var liveValue = ProductClient(
PrepareCoreDataUseCase(repository: PreparePersistentRepository.live),
getProductUseCase: ProductUseCase(repository: RemoteProductRepository.live),
saveProductUseCase: SaveProductUseCase(
repository: PersistentProductRepository.live))
public static var testValue = AppClient(
public static var testValue = ProductClient(
PrepareCoreDataUseCase(repository: PreparePersistentRepository.live),
getProductUseCase: ProductUseCase(repository: RemoteProductRepository.stubbed),
saveProductUseCase: SaveProductUseCase(
repository: PersistentProductRepository.live))
public static var previewValue = AppClient(
public static var previewValue = ProductClient(
PrepareCoreDataUseCase(repository: PreparePersistentRepository.live),
getProductUseCase: ProductUseCase(repository: RemoteProductRepository.stubbed),
saveProductUseCase: SaveProductUseCase(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// AppFeature.swift
// ProductFeature.swift
// Features
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand All @@ -11,7 +11,7 @@ import ComposableArchitecture
import Counter
import Domain

public struct AppFeature: FeatureReducer {
public struct ProductFeature: FeatureReducer {

@Dependency(\.appClient) var appClient

Expand Down Expand Up @@ -92,9 +92,7 @@ public struct AppFeature: FeatureReducer {
}
}

public func reduce(into state: inout State, internalAction: InternalAction)
-> Effect<Action>
{
public func reduce(into state: inout State, internalAction: InternalAction) -> Effect<Action> {
switch internalAction {
case let .productResponse(.success(product)):
state.product = product
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// AppView.swift
// ProductView.swift
// Features
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand All @@ -12,10 +12,10 @@ import Counter
import SwiftUI

@MainActor
public struct AppView: View {
let store: StoreOf<AppFeature>
public struct ProductView: View {
let store: StoreOf<ProductFeature>

public init(store: StoreOf<AppFeature>) {
public init(store: StoreOf<ProductFeature>) {
self.store = store
}

Expand Down Expand Up @@ -56,24 +56,24 @@ public struct AppView: View {
}
}

extension StoreOf<AppFeature> {
extension StoreOf<ProductFeature> {
fileprivate var bindableDestination:
ComposableArchitecture.Bindable<StoreOf<AppFeature>>
ComposableArchitecture.Bindable<StoreOf<ProductFeature>>
{
return ComposableArchitecture.Bindable(self)
}
}

@MainActor
extension View {
fileprivate func destinations(with store: StoreOf<AppFeature>) -> some View {
fileprivate func destinations(with store: StoreOf<ProductFeature>) -> some View {
let bindableDestination = store.bindableDestination
return showSheet(with: bindableDestination)
.showFulllScreenCover(with: bindableDestination)
}

private func showSheet(
with destinationStore: ComposableArchitecture.Bindable<StoreOf<AppFeature>>
with destinationStore: ComposableArchitecture.Bindable<StoreOf<ProductFeature>>
) -> some View {
let destinationStore = destinationStore.scope(
state: \.destination?.sheet,
Expand All @@ -85,7 +85,7 @@ extension View {
}

private func showFulllScreenCover(
with destinationStore: ComposableArchitecture.Bindable<StoreOf<AppFeature>>
with destinationStore: ComposableArchitecture.Bindable<StoreOf<ProductFeature>>
) -> some View {
let destinationStore = destinationStore.scope(
state: \.destination?.fullScreenCover,
Expand All @@ -98,11 +98,11 @@ extension View {
}

#Preview {
AppView(
ProductView(
store:
.init(
initialState: AppFeature.State(),
reducer: { AppFeature() }
initialState: ProductFeature.State(),
reducer: { ProductFeature() }
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// BuildConfiguration.swift
// NetworkPlatform
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// AppAPI.swift
// NetworkPlatform
//
// Created by Rokon on 24/01/2024.
// Copyright © 2024 MLBD. All rights reserved.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

import BuildConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// AuthAPI.swift
// NetworkPlatform
//
// Created by Rokon on 24/01/2024.
// Copyright © 2024 MLBD. All rights reserved.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// HTTPStatusCode.swift
// NetworkPlatform
//
// Created by Rokon on 24/01/2024.
// Copyright © 2024 MLBD. All rights reserved.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// LocalNotification.swift
// NetworkPlatform
//
// Created by Rokon on 24/01/2024.
// Copyright © 2024 MLBD. All rights reserved.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

import Combine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Stubbable.swift
// NetworkPlatform
//
// Created by Rokon on 24/01/2024.
// Copyright © 2024 MLBD. All rights reserved.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// AppNetworking.swift
// NetworkPlatform
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Networking.swift
// NetworkPlatform
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// NetworkingError.swift
// NetworkPlatform
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// NetworkingType.swift
// NetworkPlatform
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// NetworkRepository.swift
// NetworkPlatform
//
// Created by {{ cookiecutter.creator }} on {% now 'utc', '%d/%m/%Y' %}.
// Created by {{cookiecutter.creator}} on {% now 'utc', '%d/%m/%Y' %}.
// Copyright © {% now 'utc', '%Y' %} {{cookiecutter.company_name}}. All rights reserved.
//

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": 1,
"title": "Rokon",
"price": 109.95,
"title": "Apple Watch",
"price": 250,
"description": "Your perfect pack for everyday use and walks in the forest. Stash your laptop (up to 15 inches) in the padded sleeve, your everyday",
"category": "men's clothing",
"image": "https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg",
Expand Down
Loading

0 comments on commit ab76f2e

Please sign in to comment.