Skip to content

Commit

Permalink
test: UserStore Observe test 코드 추가, #166 - unlock피자 메소드는 메모리상에서 변경후 r…
Browse files Browse the repository at this point in the history
…ealm disk에 반영시킨다. observe하는 token이 필요 없음
  • Loading branch information
hyeonghwan committed Nov 8, 2023
1 parent 9d064ca commit ded8c9a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Pickle/PickleTests/StoreTest/UserStoreTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ final class UserStoreTest: XCTestCase {
XCTAssertEqual(sut.user.currentPizzaSlice, 0)
}

/// 특정 피자만 unlock 하는 update 테스트
/// 1. 유저 추가
/// 2. unlockPizza 메소드 호출
/// 3. fetch 호출이 아닌 observe 하고 있는 notifiction으로 업데이트
/// 4. 결과 확인
func test_update_observeTest() async throws {
// Given
try await addingAndFetchUser()
let potato = sut.user.pizzas.filter { $0.image == "potato" }.first!
XCTAssertEqual(potato.lock, true)

// When
sut.unLockPizza(pizza: potato)
await waitTask(for: 1)

// Then
let potatoPizzas = sut.user.pizzas.filter { $0.image == "potato" }.first!
XCTAssertEqual(potatoPizzas.lock, false)
}

/// Default User 추가후 fetch해오는 함수
private func addingAndFetchUser() async throws {
let user = User.defaultUser
Expand Down

0 comments on commit ded8c9a

Please sign in to comment.