This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Get details of a mint with the given ID - Get a list of mints
- Loading branch information
1 parent
b81cf42
commit 91ee53e
Showing
4 changed files
with
207 additions
and
2 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
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,71 @@ | ||
import Foundation | ||
@testable import ImmutableXCore | ||
|
||
final class MintsAPIMock: MintsAPI { | ||
class GetMintCompanion { | ||
var throwableError: Error? | ||
var callsCount = 0 | ||
var returnValue: Mint! | ||
} | ||
|
||
class ListMintsCompanion { | ||
var throwableError: Error? | ||
var callsCount = 0 | ||
var returnValue: ListMintsResponse! | ||
} | ||
|
||
static var getMintCompanion: GetMintCompanion? | ||
static var listMintsCompanion: ListMintsCompanion? | ||
|
||
static func mock(_ companion: GetMintCompanion) { | ||
getMintCompanion = companion | ||
} | ||
|
||
static func mock(_ companion: ListMintsCompanion) { | ||
listMintsCompanion = companion | ||
} | ||
|
||
static func resetMock() { | ||
getMintCompanion = nil | ||
listMintsCompanion = nil | ||
} | ||
|
||
override class func getMint(id: String) async throws -> Mint { | ||
let companion = getMintCompanion! | ||
companion.callsCount += 1 | ||
|
||
if let error = companion.throwableError { | ||
throw error | ||
} | ||
|
||
return companion.returnValue | ||
} | ||
|
||
override class func listMints( | ||
pageSize: Int? = nil, | ||
cursor: String? = nil, | ||
orderBy: String? = nil, | ||
direction: String? = nil, | ||
user: String? = nil, | ||
status: String? = nil, | ||
minTimestamp: String? = nil, | ||
maxTimestamp: String? = nil, | ||
tokenType: String? = nil, | ||
tokenId: String? = nil, | ||
assetId: String? = nil, | ||
tokenName: String? = nil, | ||
tokenAddress: String? = nil, | ||
minQuantity: String? = nil, | ||
maxQuantity: String? = nil, | ||
metadata: String? = nil | ||
) async throws -> ListMintsResponse { | ||
let companion = listMintsCompanion! | ||
companion.callsCount += 1 | ||
|
||
if let error = companion.throwableError { | ||
throw error | ||
} | ||
|
||
return companion.returnValue | ||
} | ||
} |
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