ActionSheetPopoverPresenterTests.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // ActionSheetPopoverPresenterTests.swift
  3. // SheeeeeeeeetTests
  4. //
  5. // Created by Daniel Saidi on 2018-10-18.
  6. // Copyright © 2018 Daniel Saidi. All rights reserved.
  7. //
  8. // TODO: Write more tests
  9. import Quick
  10. import Nimble
  11. @testable import Sheeeeeeeeet
  12. class ActionSheetPopoverPresenterTests: QuickSpec {
  13. override func spec() {
  14. var presenter: ActionSheetPopoverPresenter!
  15. var sheet: ActionSheet!
  16. var headerView: UIView!
  17. beforeEach {
  18. let items: [ActionSheetItem] = [
  19. ActionSheetSingleSelectItem(title: "item 1", isSelected: true),
  20. ActionSheetCancelButton(title: "cancel"),
  21. ActionSheetOkButton(title: "ok"),
  22. ActionSheetMultiSelectItem(title: "item 2", isSelected: true)
  23. ]
  24. headerView = UIView(frame: .zero)
  25. sheet = ActionSheet(items: items) { (_, _) in }
  26. sheet.headerView = headerView
  27. presenter = ActionSheetPopoverPresenter()
  28. }
  29. describe("background tap dismissal") {
  30. it("is enabled by default") {
  31. expect(presenter.isDismissableWithTapOnBackground).to(beTrue())
  32. }
  33. }
  34. describe("setting up sheet for popover presentation") {
  35. beforeEach {
  36. presenter.setupSheetForPresentation(sheet)
  37. }
  38. it("removes header view") {
  39. expect(sheet.headerView).to(beNil())
  40. }
  41. it("moves non-cancel buttons last into items group") {
  42. expect(sheet.items.count).to(equal(3))
  43. expect(sheet.buttons.count).to(equal(0))
  44. expect(sheet.items[0] is ActionSheetSingleSelectItem).to(beTrue())
  45. expect(sheet.items[1] is ActionSheetMultiSelectItem).to(beTrue())
  46. expect(sheet.items[2] is ActionSheetOkButton).to(beTrue())
  47. }
  48. }
  49. }
  50. }