Skip to content

Commit

Permalink
#194 Editando testes e corrigindo acento
Browse files Browse the repository at this point in the history
  • Loading branch information
vital14 committed May 6, 2021
1 parent 27e00fe commit 10728c1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hortum_mobile/lib/components/form_validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FormValidation {
} else if (value.length != 11) {
return "O celular deve ter 11 dígitos";
} else if (!regExp.hasMatch(value)) {
return "O número do celular so deve conter dígitos";
return "O número do celular deve conter dígitos";
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion hortum_mobile/lib/data/user_data_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class UserAPI {
return status <= 500;
},
));
return response.statusCode;
return response;
}

Future changePassword(String actualPassword, String newPassword) async {
Expand Down
14 changes: 12 additions & 2 deletions hortum_mobile/lib/views/profile/services/profile_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class ProfileServices {
phone_number: phone_number_form);
}

if (response == 400) {
if (response.statusCode == 400) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
key: Key('emailJaExistente'),
title: Text("Erro!"),
content: Text(
"Email já registrado!",
announErrorFormart(response.data.toString()),
style: TextStyle(
fontFamily: 'Roboto',
fontSize: 16,
Expand Down Expand Up @@ -73,3 +73,13 @@ class ProfileServices {
}
}
}

String announErrorFormart(String responseMsg) {
if (responseMsg ==
("{phone_number: [user with this phone number already exists.]}"))
return 'Telefone já cadastrado!';
else if (responseMsg == ("{email: [user with this email already exists.]}"))
return 'Email já cadastrado!';
else
return 'Email e telefone já cadastrados!';
}
2 changes: 1 addition & 1 deletion hortum_mobile/test/components/form_validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void main() {
});
test('Given an non empty and with symbols phone number return null', () {
String result = FormValidation.validatePhone('sadossewsdw');
expect(result, 'O número do celular so deve conter dígitos');
expect(result, 'O número do celular deve conter dígitos');
});
test('Given an non empty and valid phone number return null', () {
String result = FormValidation.validatePhone('12345678910');
Expand Down
5 changes: 3 additions & 2 deletions hortum_mobile/test/data/user_data_backend_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ main() {
data: jsonEncode(responseMatcher),
requestOptions: null,
statusCode: 200));
int responseActual = await userAPI.updateUser(email: '', username: '');
Response responseActual =
await userAPI.updateUser(email: '', username: '');

expect(responseActual, 200);
expect(responseActual.statusCode, 200);
});

test('Delete User Successful', () async {
Expand Down

0 comments on commit 10728c1

Please sign in to comment.