diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 0a7925b544..5e3c5f1133 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -705,6 +705,7 @@ 9F1061652C9C013F008DD5A0 /* DefaultVariantManager+Onboarding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F1061642C9C013F008DD5A0 /* DefaultVariantManager+Onboarding.swift */; }; 9F1623092C9D14F10093C4FC /* DefaultVariantManagerOnboardingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F1623082C9D14F10093C4FC /* DefaultVariantManagerOnboardingTests.swift */; }; 9F16230B2CA0F0190093C4FC /* DebouncerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F16230A2CA0F0190093C4FC /* DebouncerTests.swift */; }; + 9F1798572CD2443F0073018B /* AddToDockPromoViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F1798562CD2443F0073018B /* AddToDockPromoViewModelTests.swift */; }; 9F23B8012C2BC94400950875 /* OnboardingBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F23B8002C2BC94400950875 /* OnboardingBackground.swift */; }; 9F23B8032C2BCD0000950875 /* DaxDialogStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F23B8022C2BCD0000950875 /* DaxDialogStyles.swift */; }; 9F23B8062C2BE22700950875 /* OnboardingIntroViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F23B8052C2BE22700950875 /* OnboardingIntroViewModelTests.swift */; }; @@ -2504,6 +2505,7 @@ 9F1061642C9C013F008DD5A0 /* DefaultVariantManager+Onboarding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DefaultVariantManager+Onboarding.swift"; sourceTree = ""; }; 9F1623082C9D14F10093C4FC /* DefaultVariantManagerOnboardingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultVariantManagerOnboardingTests.swift; sourceTree = ""; }; 9F16230A2CA0F0190093C4FC /* DebouncerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebouncerTests.swift; sourceTree = ""; }; + 9F1798562CD2443F0073018B /* AddToDockPromoViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddToDockPromoViewModelTests.swift; sourceTree = ""; }; 9F23B8002C2BC94400950875 /* OnboardingBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingBackground.swift; sourceTree = ""; }; 9F23B8022C2BCD0000950875 /* DaxDialogStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaxDialogStyles.swift; sourceTree = ""; }; 9F23B8052C2BE22700950875 /* OnboardingIntroViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingIntroViewModelTests.swift; sourceTree = ""; }; @@ -4776,6 +4778,7 @@ 9FDEC7B92C9006E000C7A692 /* BrowserComparisonModelTests.swift */, 9F1623082C9D14F10093C4FC /* DefaultVariantManagerOnboardingTests.swift */, 9F8E0F322CCA642D001EA7C5 /* VideoPlayerViewModelTests.swift */, + 9F1798562CD2443F0073018B /* AddToDockPromoViewModelTests.swift */, ); name = Onboarding; sourceTree = ""; @@ -8044,6 +8047,7 @@ C1D21E2F293A599C006E5A05 /* AutofillLoginSessionTests.swift in Sources */, 85D2187924BF6B8B004373D2 /* FaviconSourcesProviderTests.swift in Sources */, 9F69331B2C5A16E200CD6A5D /* OnboardingDaxFavouritesTests.swift in Sources */, + 9F1798572CD2443F0073018B /* AddToDockPromoViewModelTests.swift in Sources */, 6F7FB8E52C66158D00867DA7 /* NewTabPageShortcutsSettingsModelTests.swift in Sources */, 983BD6B52B34760600AAC78E /* MockPrivacyConfiguration.swift in Sources */, 1E8146AD28C8ABF000D1AF63 /* TrackerAnimationLogicTests.swift in Sources */, diff --git a/DuckDuckGoTests/AddToDockPromoViewModelTests.swift b/DuckDuckGoTests/AddToDockPromoViewModelTests.swift new file mode 100644 index 0000000000..d8e7b22ee9 --- /dev/null +++ b/DuckDuckGoTests/AddToDockPromoViewModelTests.swift @@ -0,0 +1,97 @@ +// +// AddToDockPromoViewModelTests.swift +// DuckDuckGo +// +// Copyright © 2024 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import XCTest +import Lottie +@testable import DuckDuckGo + +final class AddToDockPromoViewModelTests: XCTestCase { + private var sut: AddToDockPromoViewModel! + private var managerMock: AppIconManagerMock! + + override func setUpWithError() throws { + try super.setUpWithError() + + managerMock = .init() + sut = .init(appIconManager: managerMock) + } + + override func tearDownWithError() throws { + managerMock = nil + sut = nil + try super.tearDownWithError() + } + + func testWhenColorIsCalledThenReturnExpectedColor() { + // GIVEN + managerMock.appIcon = .red + + // WHEN + var result = sut.color + + // THEN + XCTAssertEqual(result, LottieColor(r: 0.87, g: 0.34, b: 0.2, a: 1.0)) + + // GIVEN + managerMock.appIcon = .yellow + + // WHEN + result = sut.color + + // THEN + XCTAssertEqual(result, LottieColor(r: 0.89, g: 0.64, b: 0.07, a: 1.0)) + + // GIVEN + managerMock.appIcon = .green + + // WHEN + result = sut.color + + // THEN + XCTAssertEqual(result, LottieColor(r: 0.22, g: 0.62, b: 0.16, a: 1.0)) + + // GIVEN + managerMock.appIcon = .blue + + // WHEN + result = sut.color + + // THEN + XCTAssertEqual(result, LottieColor(r: 0.22, g: 0.41, b: 0.94, a: 1.0)) + + // GIVEN + managerMock.appIcon = .purple + + // WHEN + result = sut.color + + // THEN + XCTAssertEqual(result, LottieColor(r: 0.42, g: 0.31, b: 0.73, a: 1.0)) + + // GIVEN + managerMock.appIcon = .black + + // WHEN + result = sut.color + + // THEN + XCTAssertEqual(result, LottieColor(r: 0, g: 0, b: 0, a: 1.0)) + } + +}