Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test account and comment validation #358

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions test/models/ui/validation/create_account_validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,55 @@ void main() {
);

expect(createAccount, createAccountCopy);
expect(createAccount == createAccountCopy, true);
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved
});

test("equality fails on different uniqueUsernameError", () {
const createAccount = CreateAccountValidation(
uniqueUsernameError: "uniqueUsernameError",
pseudoError: "pseudoError",
accountCreated: true,
);

const createAccountCopy = CreateAccountValidation(
uniqueUsernameError: "uniqueUsernameError2",
pseudoError: "pseudoError",
accountCreated: true,
);

expect(createAccount == createAccountCopy, false);
});

test("equality fails on different pseudoError", () {
const createAccount = CreateAccountValidation(
uniqueUsernameError: "uniqueUsernameError",
pseudoError: "pseudoError",
accountCreated: true,
);

const createAccountCopy = CreateAccountValidation(
uniqueUsernameError: "uniqueUsernameError",
pseudoError: "pseudoError2",
accountCreated: true,
);

expect(createAccount == createAccountCopy, false);
});

test("equality fails on different accountCreated", () {
const createAccount = CreateAccountValidation(
uniqueUsernameError: "uniqueUsernameError",
pseudoError: "pseudoError",
accountCreated: true,
);

const createAccountCopy = CreateAccountValidation(
uniqueUsernameError: "uniqueUsernameError",
pseudoError: "pseudoError",
accountCreated: false,
);

expect(createAccount == createAccountCopy, false);
});
});
}
69 changes: 69 additions & 0 deletions test/models/ui/validation/new_comment_validation_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import "package:flutter_test/flutter_test.dart";
import "package:proxima/models/ui/validation/new_comment_validation.dart";

void main() {
group("New Comment Model Testing", () {
test("hash overrides correctly", () {
// Define the expected result
final newCommentState = NewCommentValidation(
contentError: "contentError",
posted: true,
);

final expectedHash = Object.hash(
newCommentState.contentError,
newCommentState.posted,
);

final actualHash = newCommentState.hashCode;

expect(actualHash, expectedHash);
});

test("equality overrides correctly", () {
// Define the expected result
final newCommentState = NewCommentValidation(
contentError: "commentError",
posted: true,
);

final newCommentStateCopy = NewCommentValidation(
contentError: "commentError",
posted: true,
);

expect(newCommentState, newCommentStateCopy);
expect(newCommentState == newCommentStateCopy, true);
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved
});

test("equality fails on different contentError", () {
// Define the expected result
final newCommentState = NewCommentValidation(
contentError: "commentError",
posted: true,
);

final newCommentStateCopy = NewCommentValidation(
contentError: "commentError2",
posted: true,
);

expect(newCommentState == newCommentStateCopy, false);
});

test("equality fails on different posted", () {
// Define the expected result
final newCommentState = NewCommentValidation(
contentError: "commentError",
posted: true,
);

final newCommentStateCopy = NewCommentValidation(
contentError: "commentError",
posted: false,
);

expect(newCommentState == newCommentStateCopy, false);
});
});
}
2 changes: 1 addition & 1 deletion test/models/ui/validation/new_post_validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "package:flutter_test/flutter_test.dart";
import "package:proxima/models/ui/validation/new_post_validation.dart";

void main() {
group("Create Account Model testing", () {
group("New Post Model testing", () {
test("hash overrides correctly", () {
final newPostState = NewPostValidation(
titleError: "titleError",
Expand Down