fix tests

This commit is contained in:
Romulus21
2024-02-24 23:15:14 +01:00
parent a818daeb38
commit 6dd147c3e2
4 changed files with 28 additions and 9 deletions

View File

@@ -32,7 +32,7 @@ test('an user can retrieve his to dos', function () {
Sanctum::actingAs($this->user);
ToDo::factory()->count(10)->create([
'user_id' => $this->user->id,
'checked' => false,
'checked' => null,
]);
$response = $this->get('api/todos');
@@ -48,6 +48,25 @@ test('an user can retrieve his to dos', function () {
->assertJson($toDos);
});
test('an user can retrieve his finished to dos', function () {
Sanctum::actingAs($this->user);
ToDo::factory()->count(10)->create([
'user_id' => $this->user->id,
]);
$response = $this->get('api/todos/finished');
$toDos = $this->user->toDos()->whereNotNull('checked')->get()->map(fn ($toDo) => [
'id' => $toDo->id,
'user_id' => $toDo->user_id,
'name' => $toDo->name,
'checked' => now(),
])->toArray();
$response->assertOk()
->assertJson($toDos);
});
test('an user can retrieve a to do', function () {
Sanctum::actingAs($this->user);
$toDos = ToDo::factory()->count(10)->create([