Skip to content

Commit ff2b88c

Browse files
[PM-28540] Add AuthenticatorSharedMocks target (#2159)
1 parent ab75131 commit ff2b88c

15 files changed

+73
-89
lines changed

AuthenticatorBridgeKit/Tests/TestHelpers/Fixtures/AuthenticatorBridgeItemDataView+Fixtures.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import Foundation
22

33
@testable import AuthenticatorBridgeKit
44

5-
extension AuthenticatorBridgeItemDataView {
5+
// swiftlint:disable missing_docs
6+
7+
public extension AuthenticatorBridgeItemDataView {
68
static func fixture(
79
accountDomain: String? = "",
810
accountEmail: String? = "",
@@ -23,6 +25,16 @@ extension AuthenticatorBridgeItemDataView {
2325
)
2426
}
2527

28+
static func fixtureFilled() -> AuthenticatorBridgeItemDataView {
29+
.fixture(
30+
accountDomain: "Domain",
31+
accountEmail: "[email protected]",
32+
name: "Name",
33+
totpKey: "TOTP",
34+
username: "username",
35+
)
36+
}
37+
2638
static func fixtures() -> [AuthenticatorBridgeItemDataView] {
2739
[
2840
AuthenticatorBridgeItemDataView.fixture(),
@@ -39,3 +51,5 @@ extension AuthenticatorBridgeItemDataView {
3951
]
4052
}
4153
}
54+
55+
// swiftlint:enable missing_docs
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import TestHelpers
22

3-
/// `APITestData` helpers that load the resource from the `AuthenticatorShared` bundle.
3+
/// `APITestData` helpers that load the resource from the `AuthenticatorSharedMocks` bundle.
44
extension APITestData {
55
static func loadFromBundle(resource: String, extension: String) -> APITestData {
6-
loadFromBundle(resource: resource, extension: `extension`, bundle: .authenticatorShared)
6+
loadFromBundle(resource: resource, extension: `extension`, bundle: .authenticatorSharedMocks)
77
}
88

99
static func loadFromJsonBundle(resource: String) -> APITestData {
10-
loadFromJsonBundle(resource: resource, bundle: .authenticatorShared)
10+
loadFromJsonBundle(resource: resource, bundle: .authenticatorSharedMocks)
1111
}
1212
}

AuthenticatorShared/Core/Platform/Services/API/Fixtures/AuthenticatorSharedBundleFinder.swift

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Foundation
2+
3+
class AuthenticatorSharedMocksBundleFinder {
4+
static let bundle = Bundle(for: AuthenticatorSharedMocksBundleFinder.self)
5+
}
6+
7+
public extension Bundle {
8+
/// The bundle for the `AuthenticatorSharedMocks` target.
9+
static let authenticatorSharedMocks = AuthenticatorSharedMocksBundleFinder.bundle
10+
}

AuthenticatorShared/Core/Vault/Models/Domain/Fixtures/AuthenticatorBridgeItemDataView+Fixtures.swift

Lines changed: 0 additions & 52 deletions
This file was deleted.

AuthenticatorShared/Core/Vault/Models/Domain/Fixtures/ItemListItem+Fixtures.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import AuthenticatorBridgeKit
2+
import AuthenticatorBridgeKitMocks
23
import BitwardenSdk
34
import Foundation
45

56
@testable import AuthenticatorShared
67

7-
extension ItemListSection {
8+
// swiftlint:disable missing_docs
9+
10+
public extension ItemListSection {
811
static func fixture() -> ItemListSection {
912
ItemListSection(
1013
id: "example",
@@ -14,7 +17,7 @@ extension ItemListSection {
1417
}
1518
}
1619

17-
extension ItemListItem {
20+
public extension ItemListItem {
1821
static func fixture(
1922
id: String = "123",
2023
name: String = "Name",
@@ -44,7 +47,7 @@ extension ItemListItem {
4447
}
4548
}
4649

47-
extension ItemListTotpItem {
50+
public extension ItemListTotpItem {
4851
static func fixture(
4952
itemView: AuthenticatorItemView = .fixture(),
5053
totpCode: TOTPCodeModel = TOTPCodeModel(
@@ -60,7 +63,7 @@ extension ItemListTotpItem {
6063
}
6164
}
6265

63-
extension ItemListSharedTotpItem {
66+
public extension ItemListSharedTotpItem {
6467
static func fixture(
6568
itemView: AuthenticatorBridgeItemDataView = .fixtureFilled(),
6669
totpCode: TOTPCodeModel = TOTPCodeModel(
@@ -75,3 +78,5 @@ extension ItemListSharedTotpItem {
7578
)
7679
}
7780
}
81+
82+
// swiftlint:enable missing_docs

AuthenticatorShared/Core/Vault/Services/TestHelpers/ImportTestData.swift renamed to AuthenticatorShared/Core/Vault/Services/Fixtures/ImportTestData.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import Foundation
22

3+
// swiftlint:disable missing_docs
4+
35
/// A type that wraps import format fixture data for use in tests.
46
///
5-
struct ImportTestData {
6-
let data: Data
7+
public struct ImportTestData {
8+
public let data: Data
79

810
static func loadFromBundle(resource: String, extension: String) -> ImportTestData {
9-
let bundle = Bundle(for: BitwardenTestCase.self)
11+
let bundle = AuthenticatorSharedMocksBundleFinder.bundle
1012
guard let url = bundle.url(forResource: resource, withExtension: `extension`) else {
1113
fatalError("Unable to locate file \(resource).\(`extension`) in the bundle.")
1214
}
@@ -22,9 +24,11 @@ struct ImportTestData {
2224
}
2325
}
2426

25-
extension ImportTestData {
27+
public extension ImportTestData {
2628
static let bitwardenJson = loadFromJsonBundle(resource: "BitwardenExport")
2729
static let lastpassJson = loadFromJsonBundle(resource: "LastpassExport")
2830
static let raivoJson = loadFromJsonBundle(resource: "RaivoExport")
2931
static let twoFasJson = loadFromBundle(resource: "TwoFasExport", extension: "2fas")
3032
}
33+
34+
// swiftlint:enable missing_docs

AuthenticatorShared/Core/Vault/Services/Importers/BitwardenImporterTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import AuthenticatorSharedMocks
12
import XCTest
23

34
@testable import AuthenticatorShared

AuthenticatorShared/Core/Vault/Services/Importers/LastpassImporterTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import AuthenticatorSharedMocks
12
import XCTest
23

34
@testable import AuthenticatorShared

AuthenticatorShared/Core/Vault/Services/Importers/RaivoImporterTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import AuthenticatorSharedMocks
12
import XCTest
23

34
@testable import AuthenticatorShared

0 commit comments

Comments
 (0)