Last active
June 3, 2019 11:18
-
-
Save tilltue/d1459b06e0f00ee70bd82f489f646fa8 to your computer and use it in GitHub Desktop.
ListOfPurchasesViewModel 1Step
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
//"카드 뷰모델 생성 테스트" | |
context("card") { | |
beforeEach { | |
self.initItems() | |
self.viewModel.estimatedCardViewModels | |
.asObservable().map{ [AnimatableSectionModel(model: "section\(0)", items: $0 )] }.debug().bind(to: self.bindProperty.bindViewModels).disposed(by: self.disposeBag) | |
} | |
it("db insert test") { | |
//DB에 아이템 입력시 카드 뷰모델이 생성되면 ok | |
let expectViewModel = PurchaseCardViewModel(item: self.item1) | |
Realm.save(object: self.item1) | |
//log.verbose(self.item1.id) | |
expect(self.bindProperty.bindViewModels.value[0].items.filter{ $0 == expectViewModel }.count).toEventually(equal(1), timeout: 1) | |
} | |
it("delete test") { | |
//아이텝을 삭제하고, 카드 뷰모델이 없으면 성공 / 있으면 실패 | |
let expectViewModel = PurchaseCardViewModel(item: self.item2) | |
Realm.save(object: self.item2) | |
self.viewModel.delete(item: self.item2) | |
expect(self.bindProperty.bindViewModels.value[0].items.filter{ $0 == expectViewModel }.count).toEventually(equal(0), timeout: 1) | |
} | |
it("delete all test") { | |
//아이텝을 모두 삭제하고, 카드 뷰모델이 없으면 성공 / 있으면 실패 | |
Realm.save(object: self.item1) | |
Realm.save(object: self.item2) | |
Realm.save(object: self.item3) | |
self.viewModel.deleteAll() | |
expect(self.bindProperty.bindViewModels.value[0].items.count).toEventually(equal(0), timeout: 1) | |
} | |
it("db update test") { | |
//DB 아이템의 내용을 변경해서 업데이트 후 뷰모델의 해당 값이 변경한 값과 같으면 성공 / 같지 않으면 실패 | |
let expectViewModel = PurchaseCardViewModel(item: self.item2) | |
Realm.save(object: self.item2) | |
let item = Item(id: expectViewModel.identity) | |
item.currency = .jpy | |
item.price = 70 | |
Realm.save(object: item) | |
expect(self.bindProperty.bindViewModels.value[0].items.filter{ $0 == expectViewModel }.first!.priceText).toEventually(equal("¥ 70"), timeout: 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment