From 737b70387e7b84c81574e565bf49a1901b9d6dea Mon Sep 17 00:00:00 2001 From: Nadya Karaban Date: Mon, 3 Feb 2025 18:09:54 +0100 Subject: [PATCH] fix(BankSDKExample): Fix Sonar cloud issues in GalleryManagerTests PP-194 --- .../CaptureSDKTests/GalleryManagerTests.swift | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/BankSDK/GiniBankSDKExample/Tests/UnitTests/CaptureSDKTests/GalleryManagerTests.swift b/BankSDK/GiniBankSDKExample/Tests/UnitTests/CaptureSDKTests/GalleryManagerTests.swift index 971b1bdfa..2f94edce0 100644 --- a/BankSDK/GiniBankSDKExample/Tests/UnitTests/CaptureSDKTests/GalleryManagerTests.swift +++ b/BankSDK/GiniBankSDKExample/Tests/UnitTests/CaptureSDKTests/GalleryManagerTests.swift @@ -11,18 +11,29 @@ import Photos final class GalleryManagerMock: GalleryManagerProtocol { var isGalleryAccessLimited: Bool = false + var isCaching = false - var albums: [Album] = [Album(assets: [Asset(identifier: "Asset 1")], - title: "Album 1", - identifier: "Album 1"), - Album(assets: [Asset(identifier: "Asset 1"), Asset(identifier: "Asset 2")], - title: "Album 2", - identifier: "Album 2"), - Album(assets: [Asset(identifier: "Asset 1"), Asset(identifier: "Asset 2")], - title: "Album 3", - identifier: "Album 3")] + private let defaultAssets = [ + Asset(identifier: "Asset 1"), + Asset(identifier: "Asset 2") + ] + + lazy var albums: [Album] = createMockAlbums() + + private func createMockAlbums() -> [Album] { + return [ + Album(assets: [defaultAssets[0]], + title: "Album 1", + identifier: "Album 1"), + Album(assets: defaultAssets, + title: "Album 2", + identifier: "Album 2"), + Album(assets: defaultAssets, + title: "Album 3", + identifier: "Album 3") + ] + } - var isCaching = false func reloadAlbums() { } @@ -36,15 +47,19 @@ final class GalleryManagerMock: GalleryManagerProtocol { } func fetchImageData(from asset: Asset, completion: @escaping ((Data?) -> Void)) { - completion(Data(count: 10)) + completion(mockData()) } func fetchRemoteImageData(from asset: Asset, completion: @escaping ((Data?) -> Void)) { - completion(Data(count: 10)) + completion(mockData()) } func fetchImage(from asset: Asset, imageQuality: ImageQuality, completion: @escaping ((UIImage) -> Void)) { } + + private func mockData() -> Data? { + return Data(count: 10) + } } extension Asset {