ActionSheetPopoverPresenterTests.swift 1.9 KB

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