testing-nova icon indicating copy to clipboard operation
testing-nova copied to clipboard

how would you testing a delete route?

Open wajeht opened this issue 2 years ago • 0 comments

how can I test a delete route? I keep getting 200 responses.

beforeEach(function () {
    Post::factory(2)->create();
    $this->superAdmin = User::factory()->asSuperAdmin()->create();
    $this->user = User::factory()->create();
    $this->post = Post::all()->first();
});

// using spatie permission package
// returns 200 
it('should not be able to delete a post', function () {
    $this->actingAs($this->user)
        ->delete("/nova-api/posts?resources[]={$this->post->id}")
        ->assertForbidden();

    // dd($this->post) // still seeing this;
});

wajeht avatar Mar 16 '23 23:03 wajeht