-
Notifications
You must be signed in to change notification settings - Fork 191
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
Showing
2 changed files
with
44 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
42 changes: 42 additions & 0 deletions
42
Tests/WalletConnectPairingTests/AppPairActivationServiceTests.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,42 @@ | ||
import XCTest | ||
@testable import WalletConnectPairing | ||
@testable import TestingUtils | ||
import WalletConnectUtils | ||
|
||
final class AppPairActivationServiceTests: XCTestCase { | ||
|
||
var service: AppPairActivationService! | ||
var storageMock: WCPairingStorage! | ||
var logger: ConsoleLogger! | ||
|
||
override func setUp() { | ||
storageMock = WCPairingStorageMock() | ||
logger = ConsoleLogger() | ||
service = AppPairActivationService(pairingStorage: storageMock, logger: logger) | ||
} | ||
|
||
override func tearDown() { | ||
storageMock = nil | ||
logger = nil | ||
service = nil | ||
} | ||
|
||
func testActivate() { | ||
let topic = "topic" | ||
let pairing = WCPairing(topic: topic) | ||
let date = pairing.expiryDate | ||
|
||
storageMock.setPairing(pairing) | ||
|
||
XCTAssertFalse(pairing.active) | ||
XCTAssertNil(pairing.peerMetadata) | ||
|
||
service.activate(for: topic, peerMetadata: .stub()) | ||
|
||
let activated = storageMock.getPairing(forTopic: topic)! | ||
|
||
XCTAssertTrue(activated.active) | ||
XCTAssertNotNil(activated.peerMetadata) | ||
XCTAssertTrue(activated.expiryDate > date) | ||
} | ||
} |