forked from Jeroenbb94/FlickrFinder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab7dda9
commit 46e6df3
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Data/Tests/DataTests/Usecases/SearchPhotos/FlickrSearchPhotoErrorTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Created by Jeroen Bakker on 28/08/2023. | ||
// Copyright (c) 2023 Bleacher Report. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import Data | ||
|
||
final class FlickrSearchPhotoErrorTests: XCTestCase { | ||
|
||
func test_init_onUnsupportedInput_shouldReturnAPIEnum() throws { | ||
// given | ||
let input = 0 | ||
|
||
// when | ||
let result = FlickrSearchPhotoError(rawValue: input) | ||
|
||
// then | ||
if case .api(let flickrAPIError) = result { | ||
XCTAssertEqual(.unknown, flickrAPIError) | ||
} else { | ||
XCTFail() | ||
} | ||
} | ||
|
||
func test_Init_onSupportedInputs_shouldReturnEnum() throws { | ||
// given | ||
let inputs = [1, 2, 3, 4, 5] | ||
let expectedResults: [FlickrSearchPhotoError] = [ | ||
.tooManyTags, | ||
.unknownUser, | ||
.parameterlessSearchesDisabled, | ||
.noPermission, | ||
.userDeleted | ||
] | ||
|
||
for (index, input) in inputs.enumerated() { | ||
// when | ||
let result = FlickrSearchPhotoError(rawValue: input) | ||
// then | ||
XCTAssertEqual(expectedResults[index], result) | ||
} | ||
} | ||
} |