focused_execution_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package convey
  2. import "testing"
  3. func TestFocusOnlyAtTopLevel(t *testing.T) {
  4. output := prepare()
  5. FocusConvey("hi", t, func() {
  6. output += "done"
  7. })
  8. expectEqual(t, "done", output)
  9. }
  10. func TestFocus(t *testing.T) {
  11. output := prepare()
  12. FocusConvey("hi", t, func() {
  13. output += "1"
  14. Convey("bye", func() {
  15. output += "2"
  16. })
  17. })
  18. expectEqual(t, "1", output)
  19. }
  20. func TestNestedFocus(t *testing.T) {
  21. output := prepare()
  22. FocusConvey("hi", t, func() {
  23. output += "1"
  24. Convey("This shouldn't run", func() {
  25. output += "boink!"
  26. })
  27. FocusConvey("This should run", func() {
  28. output += "2"
  29. FocusConvey("The should run too", func() {
  30. output += "3"
  31. })
  32. Convey("The should NOT run", func() {
  33. output += "blah blah blah!"
  34. })
  35. })
  36. })
  37. expectEqual(t, "123", output)
  38. }
  39. func TestForgotTopLevelFocus(t *testing.T) {
  40. output := prepare()
  41. Convey("1", t, func() {
  42. output += "1"
  43. FocusConvey("This will be run because the top-level lacks Focus", func() {
  44. output += "2"
  45. })
  46. Convey("3", func() {
  47. output += "3"
  48. })
  49. })
  50. expectEqual(t, "1213", output)
  51. }