remove Coverage
This commit is contained in:
@@ -1,16 +1,67 @@
|
||||
<?php
|
||||
|
||||
use App\Models\ToDo;
|
||||
use App\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
test('an user can start a time tracker', function () {
|
||||
test('user can start a time tracker', function () {
|
||||
Sanctum::actingAs($user = User::factory()->create());
|
||||
$toDo = ToDo::factory()->create(['user_id' => $user->id, 'checked' => false]);
|
||||
|
||||
$this->postJson('/api/time-tracker', [])
|
||||
$this->postJson('/api/time-tracker', ['todo_id' => $toDo->id])
|
||||
->assertCreated()
|
||||
->assertJson([
|
||||
'id' => $user->timeTrackers()->value('id'),
|
||||
'user_id' => $user->id,
|
||||
'id' => $toDo->timeTrackers()->value('id'),
|
||||
'start_at' => now()->format('Y-m-d H:i:s'),
|
||||
'end_at' => null,
|
||||
'to_do' => [
|
||||
'id' => $toDo->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $toDo->name,
|
||||
'checked' => false,
|
||||
]
|
||||
]);
|
||||
});
|
||||
|
||||
test('user can retrieve his current timer', function () {
|
||||
Sanctum::actingAs($user = User::factory()->create());
|
||||
$toDo = ToDo::factory()->create(['user_id' => $user->id, 'checked' => false]);
|
||||
|
||||
$this->postJson('/api/time-tracker', ['todo_id' => $toDo->id])
|
||||
->assertCreated();
|
||||
|
||||
$this->get('/api/time-tracker/user')
|
||||
->assertOk()
|
||||
->assertJson([
|
||||
'id' => $toDo->timeTrackers()->value('id'),
|
||||
'start_at' => now()->format('Y-m-d H:i:s'),
|
||||
'end_at' => null,
|
||||
'to_do' => [
|
||||
'id' => $toDo->id,
|
||||
'user_id' => $user->id,
|
||||
'name' => $toDo->name,
|
||||
'checked' => false,
|
||||
]
|
||||
]);
|
||||
});
|
||||
|
||||
test('user has no content response if not current time tracker', function () {
|
||||
Sanctum::actingAs($user = User::factory()->create());
|
||||
|
||||
$this->get('/api/time-tracker/user')
|
||||
->assertNoContent();
|
||||
});
|
||||
|
||||
test('user can stop current time tracker', function () {
|
||||
Sanctum::actingAs($user = User::factory()->create());
|
||||
$toDo = ToDo::factory()->create(['user_id' => $user->id, 'checked' => false]);
|
||||
|
||||
$this->postJson('/api/time-tracker', ['todo_id' => $toDo->id])
|
||||
->assertCreated();
|
||||
|
||||
$this->delete('/api/time-tracker/user')
|
||||
->assertNoContent();
|
||||
|
||||
expect($toDo->timeTrackers->first())
|
||||
->end_at->format('Y-m-d H:i:s')->toBe(now()->format('Y-m-d H:i:s'));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user