ActionSheetButtonTests.swift 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // ActionSheetButtonTests.swift
  3. // Sheeeeeeeeet
  4. //
  5. // Created by Daniel Saidi on 2017-11-26.
  6. // Copyright © 2017 Daniel Saidi. All rights reserved.
  7. //
  8. import Quick
  9. import Nimble
  10. import Sheeeeeeeeet
  11. class ActionSheetButtonTests: QuickSpec {
  12. override func spec() {
  13. var item: ActionSheetButton!
  14. describe("when created with value") {
  15. it("is correctly setup") {
  16. item = ActionSheetButton(title: "foo", value: "bar")
  17. expect(item.title).to(equal("foo"))
  18. expect(item.value as? String).to(equal("bar"))
  19. expect(item.isOkButton).to(beFalse())
  20. }
  21. }
  22. describe("when created with button type") {
  23. it("is correctly setup") {
  24. item = ActionSheetButton(title: "foo", type: .ok)
  25. expect(item.title).to(equal("foo"))
  26. expect(item.value as? ActionSheetButton.ButtonType).to(equal(.ok))
  27. }
  28. }
  29. describe("cell") {
  30. it("is of correct type") {
  31. item = ActionSheetButton(title: "foo", type: .ok)
  32. let cell = item.cell(for: UITableView())
  33. expect(cell is ActionSheetButtonCell).to(beTrue())
  34. expect(cell.reuseIdentifier).to(equal(item.cellReuseIdentifier))
  35. }
  36. }
  37. describe("button type") {
  38. func createItem(type: ActionSheetButton.ButtonType) -> ActionSheetButton {
  39. return ActionSheetButton(title: "foo", type: type)
  40. }
  41. it("is correct for each button type") {
  42. expect(createItem(type: .cancel).isOkButton).to(beFalse())
  43. expect(createItem(type: .cancel).isCancelButton).to(beTrue())
  44. expect(createItem(type: .ok).isOkButton).to(beTrue())
  45. expect(createItem(type: .ok).isCancelButton).to(beFalse())
  46. }
  47. }
  48. }
  49. }
  50. class ActionSheetButtonCellTests: QuickSpec {
  51. override func spec() {
  52. describe("refreshing") {
  53. it("center aligns text label") {
  54. let item = ActionSheetButton(title: "", value: nil)
  55. let cell = item.cell(for: UITableView())
  56. cell.refresh()
  57. expect(cell.textLabel?.textAlignment).to(equal(.center))
  58. }
  59. }
  60. }
  61. }