2021-10-26 16:14:03 -07:00
|
|
|
//
|
|
|
|
// RecoveryPhraseDisplayStoreTests.swift
|
|
|
|
// secantTests
|
|
|
|
//
|
|
|
|
// Created by Francisco Gindre on 12/8/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
import ComposableArchitecture
|
2023-05-31 00:49:37 -07:00
|
|
|
import Pasteboard
|
2023-05-30 23:29:32 -07:00
|
|
|
import Models
|
2023-06-01 07:11:37 -07:00
|
|
|
import RecoveryPhraseDisplay
|
2021-10-26 16:14:03 -07:00
|
|
|
@testable import secant_testnet
|
|
|
|
|
|
|
|
class RecoveryPhraseDisplayReducerTests: XCTestCase {
|
|
|
|
func testCopyToBuffer() {
|
2022-11-18 02:34:33 -08:00
|
|
|
let testPasteboard = PasteboardClient.testPasteboard
|
|
|
|
|
2021-10-26 16:14:03 -07:00
|
|
|
let store = TestStore(
|
2022-11-01 09:36:37 -07:00
|
|
|
initialState: RecoveryPhraseDisplayStore.test,
|
2022-11-04 23:11:25 -07:00
|
|
|
reducer: RecoveryPhraseDisplayReducer()
|
2023-03-21 03:03:42 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
store.dependencies.pasteboard = testPasteboard
|
2022-11-17 03:25:55 -08:00
|
|
|
|
2023-03-21 03:03:42 -07:00
|
|
|
store.send(.copyToBufferPressed) { state in
|
|
|
|
state.phrase = .placeholder
|
|
|
|
state.showCopyToBufferAlert = true
|
2021-10-26 16:14:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
XCTAssertEqual(
|
2022-11-18 02:34:33 -08:00
|
|
|
testPasteboard.getString(),
|
2021-12-13 12:50:04 -08:00
|
|
|
RecoveryPhrase.placeholder.toString()
|
2021-10-26 16:14:03 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testNewPhrase() {
|
|
|
|
let store = TestStore(
|
2022-11-01 09:36:37 -07:00
|
|
|
initialState: RecoveryPhraseDisplayStore.empty,
|
2022-11-04 23:11:25 -07:00
|
|
|
reducer: RecoveryPhraseDisplayReducer()
|
2021-10-26 16:14:03 -07:00
|
|
|
)
|
|
|
|
|
2023-03-21 03:03:42 -07:00
|
|
|
store.send(.phraseResponse(.placeholder)) { state in
|
|
|
|
state.phrase = .placeholder
|
|
|
|
state.showCopyToBufferAlert = false
|
2021-10-26 16:14:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-01 09:36:37 -07:00
|
|
|
private extension RecoveryPhraseDisplayStore {
|
2022-11-04 23:11:25 -07:00
|
|
|
static let test = RecoveryPhraseDisplayReducer.State(
|
2021-12-13 12:50:04 -08:00
|
|
|
phrase: .placeholder,
|
2021-10-26 16:14:03 -07:00
|
|
|
showCopyToBufferAlert: false
|
|
|
|
)
|
|
|
|
|
2022-11-04 23:11:25 -07:00
|
|
|
static let empty = RecoveryPhraseDisplayReducer.State(
|
2021-10-26 16:14:03 -07:00
|
|
|
phrase: .empty,
|
|
|
|
showCopyToBufferAlert: false
|
|
|
|
)
|
|
|
|
}
|