59 lines
1.4 KiB
Swift
59 lines
1.4 KiB
Swift
//
|
|
// HistoryTests.swift
|
|
// AutoCatTests
|
|
//
|
|
// Created by Selim Mustafaev on 09.02.2025.
|
|
// Copyright © 2025 Selim Mustafaev. All rights reserved.
|
|
//
|
|
|
|
import Testing
|
|
import Mockable
|
|
import AutoCatCore
|
|
@testable import AutoCat
|
|
import Foundation
|
|
|
|
@MainActor
|
|
struct HistoryTests {
|
|
|
|
var storageServiceMock: MockStorageServiceProtocol
|
|
var apiServiceMock: MockApiServiceProtocol
|
|
var vehicleServiceMock: MockVehicleServiceProtocol
|
|
|
|
var viewModel: HistoryViewModel
|
|
|
|
init() async {
|
|
|
|
storageServiceMock = MockStorageServiceProtocol()
|
|
apiServiceMock = MockApiServiceProtocol()
|
|
vehicleServiceMock = MockVehicleServiceProtocol()
|
|
|
|
viewModel = HistoryViewModel(
|
|
apiService: apiServiceMock,
|
|
storageService: storageServiceMock,
|
|
vehicleService: vehicleServiceMock
|
|
)
|
|
}
|
|
|
|
@Test func test() async throws {
|
|
|
|
let dbURL = URL(fileURLWithPath: "testDbUrl")
|
|
|
|
given(storageServiceMock)
|
|
.loadVehicles()
|
|
.willReturn([.normal])
|
|
|
|
given(storageServiceMock)
|
|
.dbFileURL
|
|
.willReturn(dbURL)
|
|
|
|
await viewModel.onAppear()
|
|
|
|
#expect(viewModel.vehicles == [.normal])
|
|
#expect(viewModel.vehiclesFiltered == [.normal])
|
|
#expect(viewModel.vehicleSections.count == 1)
|
|
#expect(viewModel.dbFileURL == dbURL)
|
|
}
|
|
|
|
|
|
}
|