Skip to content

Commit

Permalink
Make 95 sample code build (pointfreeco#54)
Browse files Browse the repository at this point in the history
Co-authored-by: Kaan Dedeoglu <[email protected]>
  • Loading branch information
kaandedeoglu and Kaan Dedeoglu authored Mar 24, 2020
1 parent cb2f5bc commit f348e4b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import XCTest

class CounterTests: XCTestCase {
func testSnapshots() {
let store = Store(initialValue: CounterViewState(), reducer: counterViewReducer, environment: { _ in .sync { 17 } })
let store = Store(initialValue: CounterFeatureState(), reducer: counterViewReducer, environment: { _ in .sync { 17 } })
let view = CounterView(store: store)

let vc = UIHostingController(rootView: view)
Expand Down Expand Up @@ -52,7 +52,7 @@ class CounterTests: XCTestCase {

func testIncrDecrButtonTapped() {
assert(
initialValue: CounterViewState(count: 2),
initialValue: CounterFeatureState(count: 2),
reducer: counterViewReducer,
environment: { _ in .sync { 17 } },
steps:
Expand All @@ -64,20 +64,20 @@ class CounterTests: XCTestCase {

func testNthPrimeButtonHappyFlow() {
assert(
initialValue: CounterViewState(
initialValue: CounterFeatureState(
alertNthPrime: nil,
count: 7,
isNthPrimeButtonDisabled: false
isNthPrimeRequestInFlight: false
),
reducer: counterViewReducer,
environment: { _ in .sync { 17 } },
steps:
Step(.send, .counter(.nthPrimeButtonTapped)) {
$0.isNthPrimeButtonDisabled = true
$0.isNthPrimeRequestInFlight = true
},
Step(.receive, .counter(.nthPrimeResponse(n: 7, prime: 17))) {
$0.alertNthPrime = PrimeAlert(n: $0.count, prime: 17)
$0.isNthPrimeButtonDisabled = false
$0.isNthPrimeRequestInFlight = false
},
Step(.send, .counter(.alertDismissButtonTapped)) {
$0.alertNthPrime = nil
Expand All @@ -87,26 +87,26 @@ class CounterTests: XCTestCase {

func testNthPrimeButtonUnhappyFlow() {
assert(
initialValue: CounterViewState(
initialValue: CounterFeatureState(
alertNthPrime: nil,
count: 7,
isNthPrimeButtonDisabled: false
isNthPrimeRequestInFlight: false
),
reducer: counterViewReducer,
environment: { _ in .sync { nil } },
steps:
Step(.send, .counter(.nthPrimeButtonTapped)) {
$0.isNthPrimeButtonDisabled = true
$0.isNthPrimeRequestInFlight = true
},
Step(.receive, .counter(.nthPrimeResponse(n: 7, prime: nil))) {
$0.isNthPrimeButtonDisabled = false
$0.isNthPrimeRequestInFlight = false
}
)
}

func testPrimeModal() {
assert(
initialValue: CounterViewState(
initialValue: CounterFeatureState(
count: 1,
favoritePrimes: [3, 5]
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PlaygroundPage.current.liveView = UIHostingController(
alertNthPrime: nil,
count: 0,
favoritePrimes: [],
isNthPrimeButtonDisabled: false
isNthPrimeRequestInFlight: false
),
reducer: logging(counterViewReducer),
environment: { _ in .sync { 7236893748932 } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct AppState: Equatable {
var loggedInUser: User? = nil
var activityFeed: [Activity] = []
var alertNthPrime: PrimeAlert? = nil
var isNthPrimeButtonDisabled: Bool = false
var isNthPrimeRequestInFlight: Bool = false
var isPrimeModalShown: Bool = false

struct Activity: Equatable {
Expand Down Expand Up @@ -54,15 +54,15 @@ extension AppState {
alertNthPrime: self.alertNthPrime,
count: self.count,
favoritePrimes: self.favoritePrimes,
isNthPrimeButtonDisabled: self.isNthPrimeButtonDisabled,
isNthPrimeRequestInFlight: self.isNthPrimeRequestInFlight,
isPrimeModalShown: self.isPrimeModalShown
)
}
set {
self.alertNthPrime = newValue.alertNthPrime
self.count = newValue.count
self.favoritePrimes = newValue.favoritePrimes
self.isNthPrimeButtonDisabled = newValue.isNthPrimeButtonDisabled
self.isNthPrimeRequestInFlight = newValue.isNthPrimeRequestInFlight
self.isPrimeModalShown = newValue.isPrimeModalShown
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func activityFeed(
.favoritePrimes(.loadedFavoritePrimes),
.favoritePrimes(.loadButtonTapped),
.favoritePrimes(.saveButtonTapped),
.favoritePrimes(.primeButtonTapped(_)),
.favoritePrimes(.primeButtonTapped),
.favoritePrimes(.nthPrimeResponse),
.favoritePrimes(.alertDismissButtonTapped):
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class PrimeTimeTests: XCTestCase {
),
steps:
Step(.send, .counterView(.counter(.nthPrimeButtonTapped))) {
$0.isNthPrimeButtonDisabled = true
$0.isNthPrimeRequestInFlight = true
},
Step(.receive, .counterView(.counter(.nthPrimeResponse(n: 4, prime: 17)))) {
$0.isNthPrimeButtonDisabled = false
$0.isNthPrimeRequestInFlight = false
$0.alertNthPrime = PrimeAlert(n: 4, prime: 17)
},
Step(.send, .favoritePrimes(.loadButtonTapped)),
Expand Down

0 comments on commit f348e4b

Please sign in to comment.