add test
This commit is contained in:
@@ -54,6 +54,27 @@ test('user has no content response if not current time tracker', function () {
|
||||
->assertNoContent();
|
||||
});
|
||||
|
||||
test('user can retrieve a time tracker', function () {
|
||||
Sanctum::actingAs($user = User::factory()->create());
|
||||
$toDo = ToDo::factory()->create(['user_id' => $user->id, 'checked' => null]);
|
||||
$timeTracker = $toDo->timeTrackers()->create([
|
||||
'start_at' => now()->subMinutes(20),
|
||||
'end_at' => now()->subMinutes(10),
|
||||
]);
|
||||
|
||||
$this->get('/api/time-trackers/'.$timeTracker->id)
|
||||
->assertOk()
|
||||
->assertJson([
|
||||
'id' => $timeTracker->id,
|
||||
'start_at' => now()->subMinutes(20),
|
||||
'end_at' => now()->subMinutes(10),
|
||||
'to_do' => [
|
||||
'id' => $toDo->id,
|
||||
'user_id' => $user->id,
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
test('user can stop current time tracker', function () {
|
||||
Sanctum::actingAs($user = User::factory()->create());
|
||||
$toDo = ToDo::factory()->create(['user_id' => $user->id, 'checked' => null]);
|
||||
@@ -115,3 +136,18 @@ test('user can update a time tracker', function () {
|
||||
|
||||
expect($toDo->refresh())->duration->toBe(660);
|
||||
});
|
||||
|
||||
test('user can retrieve time trackers of a todo', function () {
|
||||
Sanctum::actingAs($user = User::factory()->create());
|
||||
$toDo = ToDo::factory()->create(['user_id' => $user->id, 'duration' => 600, 'checked' => null]);
|
||||
for ($i = 10; $i > 0; $i--) {
|
||||
$toDo->timeTrackers()->create([
|
||||
'start_at' => now()->subMinutes(20 + $i * 10),
|
||||
'end_at' => now()->subMinutes(10 + $i * 10),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->get("/api/todos/{$toDo->id}/time-trackers")
|
||||
->assertOk()
|
||||
->assertJsonCount(10);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user