def test_get_text_returns_set_text(self): """Given a TextField when a text is set then that text can be retrieved""" # Given textfield = gui.TextField(Rectangle(100, 100, 50, 50), gfx.Font()) TEST_TEXT = "Testing 1 2 3" # When textfield.text = TEST_TEXT # Then assert textfield.text == TEST_TEXT
def test_non_active_receives_no_input(self): """Given an non-active TextField when keys are pressed then the text isn't entered""" # Given textfield = gui.TextField(Rectangle(100, 100, 50, 50), gfx.Font()) userinput = UserInput() guistate = gui.GuiState() guistate.set_active(None) # When # loop 1 userinput.key.feed_char("A") textfield.tick(userinput, guistate) userinput.update() userinput.key.feed_char("b") textfield.tick(userinput, guistate) userinput.update() # Then assert textfield.text == ""