Skip to content

Commit 04bac6f

Browse files
committed
Cleanup/tests.
1 parent f202d88 commit 04bac6f

File tree

12 files changed

+227
-6
lines changed

12 files changed

+227
-6
lines changed

Notes/DiffableTextField.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct DiffableTextFieldXAmount: View {
5757
.bounds((0 as Decimal)...)
5858
// .precision(integer: 1..., fraction: 2)
5959
}
60-
.environment(\.locale, Locale(identifier: "en_SE"))
60+
.environment(\.locale, Locale(identifier: "sv_SE"))
6161
}
6262
}
6363
```

Notes/NumericTextStyle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct DiffableTextFieldXAmount: View {
145145
.bounds((0 as Decimal)...)
146146
// .precision(integer: 1..., fraction: 2)
147147
}
148-
.environment(\.locale, Locale(identifier: "en_SE"))
148+
.environment(\.locale, Locale(identifier: "sv_SE"))
149149
}
150150
}
151151
```

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ let package = Package(
7070
.target(
7171
name: "DiffableTextStylesXWrapper",
7272
dependencies: ["DiffableTextKit", "DiffableTextViewsXiOS"]),
73+
.testTarget(
74+
name: "DiffableTextStylesXWrapperTests",
75+
dependencies: ["DiffableTestKit", "DiffableTextStylesXWrapper"]),
7376
//=--------------------------------------=
7477
// MARK: 2 - DiffableTextViewsXiOS
7578
//=--------------------------------------=
@@ -87,7 +90,7 @@ let package = Package(
8790
dependencies: ["DiffableTextKitXiOS"]),
8891
.testTarget(
8992
name: "DiffableTextKitTests",
90-
dependencies: ["DiffableTextKit", "DiffableTestKit"]),
93+
dependencies: ["DiffableTestKit", "DiffableTextKit"]),
9194
//=--------------------------------------=
9295
// MARK: 0 - DiffableTextKitXiOS
9396
//=--------------------------------------=
@@ -96,7 +99,7 @@ let package = Package(
9699
dependencies: []),
97100
.testTarget(
98101
name: "DiffableTextKitXiOSTests",
99-
dependencies: ["DiffableTestKit"]),
102+
dependencies: ["DiffableTestKit", "DiffableTextKitXiOS"]),
100103
//=--------------------------------------=
101104
// MARK: T - DiffableTestKit
102105
//=--------------------------------------=

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct DiffableTextFieldXAmount: View {
112112
.bounds((0 as Decimal)...)
113113
// .precision(integer: 1..., fraction: 2)
114114
}
115-
.environment(\.locale, Locale(identifier: "en_SE"))
115+
.environment(\.locale, Locale(identifier: "sv_SE"))
116116
}
117117
}
118118
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//=----------------------------------------------------------------------------=
2+
// This source file is part of the DiffableTextViews open source project.
3+
//
4+
// Copyright (c) 2022 Oscar Byström Ericsson
5+
// Licensed under Apache License, Version 2.0
6+
//
7+
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+
//=----------------------------------------------------------------------------=
9+
10+
//*============================================================================*
11+
// MARK: * Kit
12+
//*============================================================================*
13+
14+
@_exported import protocol DiffableTextKit.DiffableTextStyle
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//=----------------------------------------------------------------------------=
2+
// This source file is part of the DiffableTextViews open source project.
3+
//
4+
// Copyright (c) 2022 Oscar Byström Ericsson
5+
// Licensed under Apache License, Version 2.0
6+
//
7+
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+
//=----------------------------------------------------------------------------=
9+
10+
//*============================================================================*
11+
// MARK: * Kit
12+
//*============================================================================*
13+
14+
@_exported import protocol DiffableTextKit.DiffableTextStyle
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//=----------------------------------------------------------------------------=
2+
// This source file is part of the DiffableTextViews open source project.
3+
//
4+
// Copyright (c) 2022 Oscar Byström Ericsson
5+
// Licensed under Apache License, Version 2.0
6+
//
7+
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+
//=----------------------------------------------------------------------------=
9+
10+
//*============================================================================*
11+
// MARK: * Kit
12+
//*============================================================================*
13+
14+
@_exported import protocol DiffableTextKit.DiffableTextStyle

Tests/DiffableTestKit/Constants.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
//=----------------------------------------------------------------------------=
99

1010
//*============================================================================*
11-
// MARK: * Constants
11+
// MARK: * Locales
12+
//*============================================================================*
13+
14+
public let en_US = Locale(identifier: "en_US")
15+
public let sv_SE = Locale(identifier: "sv_SE")
16+
17+
//*============================================================================*
18+
// MARK: * Strings
1219
//*============================================================================*
1320

1421
public let alphabet = "ABCDEFGHIJJKLMNOPQRSTUVWXYZ"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//=----------------------------------------------------------------------------=
2+
// This source file is part of the DiffableTextViews open source project.
3+
//
4+
// Copyright (c) 2022 Oscar Byström Ericsson
5+
// Licensed under Apache License, Version 2.0
6+
//
7+
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+
//=----------------------------------------------------------------------------=
9+
10+
import DiffableTextKit
11+
import Foundation
12+
13+
//*============================================================================*
14+
// MARK: * Mock
15+
//*============================================================================*
16+
17+
struct Mock: DiffableTextStyle {
18+
typealias Value = Int
19+
20+
//=------------------------------------------------------------------------=
21+
// MARK: State
22+
//=------------------------------------------------------------------------=
23+
24+
var locale: Locale
25+
26+
//=------------------------------------------------------------------------=
27+
// MARK: Transformations
28+
//=------------------------------------------------------------------------=
29+
30+
func locale(_ locale: Locale) -> Self {
31+
var result = self
32+
result.locale = locale
33+
return result
34+
}
35+
36+
//=------------------------------------------------------------------------=
37+
// MARK: Utilities
38+
//=------------------------------------------------------------------------=
39+
40+
func format(_ value: Value) -> String {
41+
fatalError()
42+
}
43+
44+
func interpret(_ value: Value) -> Commit<Value> {
45+
fatalError()
46+
}
47+
48+
func merge(_ changes: Changes) throws -> Commit<Value> {
49+
fatalError()
50+
}
51+
}
52+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//=----------------------------------------------------------------------------=
2+
// This source file is part of the DiffableTextViews open source project.
3+
//
4+
// Copyright (c) 2022 Oscar Byström Ericsson
5+
// Licensed under Apache License, Version 2.0
6+
//
7+
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
8+
//=----------------------------------------------------------------------------=
9+
10+
#if DEBUG
11+
12+
import DiffableTestKit
13+
@testable import DiffableTextStylesXWrapper
14+
15+
//*============================================================================*
16+
// MARK: * StyleTests x Constant
17+
//*============================================================================*
18+
19+
final class StyleTestsXConstant: Tests {
20+
21+
//=------------------------------------------------------------------------=
22+
// MARK: Tests
23+
//=------------------------------------------------------------------------=
24+
25+
func test() {
26+
//=--------------------------------------=
27+
// MARK: Setup
28+
//=--------------------------------------=
29+
let mock0 = Mock(locale: en_US).constant()
30+
let mock1 = mock0.locale(sv_SE)
31+
//=--------------------------------------=
32+
// MARK: Assert
33+
//=--------------------------------------=
34+
XCTAssertEqual(mock0, mock1)
35+
XCTAssertEqual(mock0.style.locale, mock1.style.locale)
36+
}
37+
}
38+
39+
#endif

0 commit comments

Comments
 (0)