-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented "FocusConvey". Finally fixes #52.
- Loading branch information
1 parent
d87533a
commit cf2232f
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package convey | ||
|
||
import "testing" | ||
|
||
func TestFocusOnlyAtTopLevel(t *testing.T) { | ||
output := prepare() | ||
|
||
FocusConvey("hi", t, func() { | ||
output += "done" | ||
}) | ||
|
||
expectEqual(t, "done", output) | ||
} | ||
|
||
func TestFocus(t *testing.T) { | ||
output := prepare() | ||
|
||
FocusConvey("hi", t, func() { | ||
output += "1" | ||
|
||
Convey("bye", func() { | ||
output += "2" | ||
}) | ||
}) | ||
|
||
expectEqual(t, "1", output) | ||
} | ||
|
||
func TestNestedFocus(t *testing.T) { | ||
output := prepare() | ||
|
||
FocusConvey("hi", t, func() { | ||
output += "1" | ||
|
||
Convey("This shouldn't run", func() { | ||
output += "boink!" | ||
}) | ||
|
||
FocusConvey("This should run", func() { | ||
output += "2" | ||
|
||
FocusConvey("The should run too", func() { | ||
output += "3" | ||
|
||
}) | ||
|
||
Convey("The should NOT run", func() { | ||
output += "blah blah blah!" | ||
}) | ||
}) | ||
}) | ||
|
||
expectEqual(t, "123", output) | ||
} | ||
|
||
func TestForgotTopLevelFocus(t *testing.T) { | ||
output := prepare() | ||
|
||
Convey("1", t, func() { | ||
output += "1" | ||
|
||
FocusConvey("This will be run because the top-level lacks Focus", func() { | ||
output += "2" | ||
}) | ||
|
||
Convey("3", func() { | ||
output += "3" | ||
}) | ||
}) | ||
|
||
expectEqual(t, "1213", output) | ||
} |
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
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