add test
This commit is contained in:
@@ -11,11 +11,10 @@ beforeEach(function () {
|
|||||||
test('an user can add todo', function () {
|
test('an user can add todo', function () {
|
||||||
Sanctum::actingAs($this->user);
|
Sanctum::actingAs($this->user);
|
||||||
|
|
||||||
$response = $this->post('api/todos', [
|
$this->post('api/todos', [
|
||||||
'name' => 'Test',
|
'name' => 'Test',
|
||||||
]);
|
])
|
||||||
|
->assertStatus(201)
|
||||||
$response->assertStatus(201)
|
|
||||||
->assertJson([
|
->assertJson([
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'name' => 'Test',
|
'name' => 'Test',
|
||||||
@@ -77,9 +76,8 @@ test('an user can retrieve a to do', function () {
|
|||||||
|
|
||||||
$toDo = $toDos[rand(0, 9)];
|
$toDo = $toDos[rand(0, 9)];
|
||||||
|
|
||||||
$response = $this->get('api/todos/'.$toDo->id);
|
$this->get('api/todos/'.$toDo->id)
|
||||||
|
->assertOk()
|
||||||
$response->assertOk()
|
|
||||||
->assertJson([
|
->assertJson([
|
||||||
'id' => $toDo->id,
|
'id' => $toDo->id,
|
||||||
'user_id' => $toDo->user_id,
|
'user_id' => $toDo->user_id,
|
||||||
@@ -128,9 +126,8 @@ test('an user can delete a to do', function () {
|
|||||||
|
|
||||||
$toDo = $toDos[rand(0, 9)];
|
$toDo = $toDos[rand(0, 9)];
|
||||||
|
|
||||||
$response = $this->delete('api/todos/'.$toDo->id);
|
$this->delete('api/todos/'.$toDo->id)
|
||||||
|
->assertNoContent();
|
||||||
$response->assertNoContent();
|
|
||||||
|
|
||||||
expect(ToDo::all())->toHaveCount(9);
|
expect(ToDo::all())->toHaveCount(9);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user