Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: added tests for data injection #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Data/Tests/DataTests/Injection/DataInjectionTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Created by Jeroen Bakker on 30/08/2023.
// Copyright (c) 2023 Bleacher Report. All rights reserved.
//

import XCTest
import Factory
@testable import Data

final class DataInjectionTests: XCTestCase {

func test_singletons_onUrlSession_shouldReturnSameReference() {
// given
Container.registerAllServices()

// when
let urlSession1 = Container.Singletons.urlSession.callAsFunction() as? URLSession
let urlSession2 = Container.Singletons.urlSession.callAsFunction() as? URLSession

// then
XCTAssertTrue(urlSession1 === urlSession2)
}

func test_workers_onAPI_shouldReturnService() {
// given
Container.registerAllServices()

// when
let result = Container.Workers.api.callAsFunction()

// then
XCTAssertTrue(result is APIService)
}

func test_mappers_onSearchPhotoResult_shouldReturnMapper() {
// given
Container.registerAllServices()

// when
let result = Container.Mappers.searchPhotosResult.callAsFunction()

// then
XCTAssertNotNil(result)
}

func test_mappers_onPhoto_shouldReturnMapper() {
// given
Container.registerAllServices()

// when
let result = Container.Mappers.photo.callAsFunction()

// then
XCTAssertNotNil(result)
}
}