-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testes unitários para página de contato
- Loading branch information
1 parent
8f34f84
commit 04ddad4
Showing
1 changed file
with
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pytest | ||
import importlib | ||
|
||
contato_module = importlib.import_module("frontend.pages.03_Contato") | ||
is_valid_email = contato_module.is_valid_email | ||
is_name_filled = contato_module.is_name_filled | ||
is_message_filled = contato_module.is_message_filled | ||
validate_form = contato_module.validate_form | ||
|
||
|
||
# Teste para validar email | ||
def test_is_valid_email(): | ||
assert is_valid_email("[email protected]") == True | ||
assert is_valid_email("invalid-email") == False | ||
|
||
|
||
# Teste para verificar se o campo nome está preenchido | ||
def test_is_name_filled(): | ||
assert is_name_filled("John Doe") == True | ||
assert is_name_filled("") == False | ||
|
||
|
||
# Teste para verificar se o campo mensagem está preenchido | ||
def test_is_message_filled(): | ||
assert is_message_filled("Hello, this is a message.") == True | ||
assert is_message_filled("") == False | ||
|
||
|
||
# Teste para validar o formulário | ||
def test_validate_form(): | ||
errors = validate_form("John Doe", "[email protected]", "Subject", "Message") | ||
assert errors == { | ||
"name_error": False, | ||
"email_error": False, | ||
"message_error": False, | ||
"subject_error": False, | ||
} | ||
|
||
errors = validate_form("", "invalid-email", "", "") | ||
assert errors == { | ||
"name_error": True, | ||
"email_error": True, | ||
"message_error": True, | ||
"subject_error": True, | ||
} | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main() |