Skip to content

Commit

Permalink
test: adjust tests for assertions on moderation categories
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches committed Aug 1, 2023
1 parent e85bc39 commit 776812a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ final class CreateResponseFixture
'categories' => [
'hate' => false,
'hate/threatening' => true,
'harassment' => false,
'harassment/threatening' => false,
'self-harm' => false,
'self-harm/intent' => false,
'self-harm/instructions' => false,
'sexual' => false,
'sexual/minors' => false,
'violence' => true,
Expand All @@ -21,7 +25,11 @@ final class CreateResponseFixture
'category_scores' => [
'hate' => 0.22714105248451233,
'hate/threatening' => 0.4132447838783264,
'harassment' => 0.1602763684674149,
'harassment/threatening' => 0.1602763684674149,
'self-harm' => 0.005232391878962517,
'self-harm/intent' => 0.005134391873962517,
'self-harm/instructions' => 0.005132591874962517,
'sexual' => 0.01407341007143259,
'sexual/minors' => 0.0038522258400917053,
'violence' => 0.9223177433013916,
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixtures/Moderation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ function moderationResource(): array
'categories' => [
'hate' => false,
'hate/threatening' => true,
'harassment' => false,
'harassment/threatening' => false,
'self-harm' => false,
'self-harm/intent' => false,
'self-harm/instructions' => false,
'sexual' => false,
'sexual/minors' => false,
'violence' => true,
Expand All @@ -22,7 +26,11 @@ function moderationResource(): array
'category_scores' => [
'hate' => 0.22714105248451233,
'hate/threatening' => 0.4132447838783264,
'harassment' => 0.1602763684674149,
'harassment/threatening' => 0.1602763684674149,
'self-harm' => 0.005232391878962517,
'self-harm/intent' => 0.005134391873962517,
'self-harm/instructions' => 0.005132591874962517,
'sexual' => 0.01407341007143259,
'sexual/minors' => 0.0038522258400917053,
'violence' => 0.9223177433013916,
Expand Down
7 changes: 6 additions & 1 deletion tests/Resources/Moderations.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@

expect($result->results[0])
->flagged->toBeTrue()
->categories->toHaveCount(7)
->categories->toHaveCount(11)
->each->toBeInstanceOf(CreateResponseCategory::class);

expect($result->results[0]->categories[Category::Hate->value])
->category->toBe(Category::Hate)
->violated->toBe(false)
->score->toBe(0.22714105248451233);

expect($result->results[0]->categories[Category::Violence->value])
->category->toBe(Category::Violence)
->violated->toBe(true)
->score->toBe(0.9223177433013916);
});
2 changes: 1 addition & 1 deletion tests/Responses/Moderations/CreateResponseResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

expect($result)
->flagged->toBeTrue()
->categories->toHaveCount(7)
->categories->toHaveCount(11)
->each->toBeInstanceOf(CreateResponseCategory::class);
});

Expand Down

0 comments on commit 776812a

Please sign in to comment.