<?php

namespace Tests\Api;

use Tests\TestCase;
use Illuminate\Support\Facades\Hash;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\User;

class HomeControllerTest extends TestCase
{
    use DatabaseTransactions;

    protected $adminToken;

    public function setUp()
    {
        parent::setUp();

        $admin = factory(User::class)->create();
        $admin->assignRole('Admin');

        $this->adminToken = \JWTAuth::fromUser($admin);
    }

    public function testGETVue()
    {
        $menuItems = [
            [
                'name' => 'strings.dashboard',
                'icon' => 'grid-outline',
                'link' => '/dashboard',
                'permissions' => [
                    'dashboard.index'
                ],
            ],
            [
                'name' => 'strings.customers',
                'icon' => 'people-outline',
                'link' => '/customers',
                'permissions' => [
                    'customers.index'
                ],
            ],
            [
                'name' => 'strings.users',
                'icon' => 'people-outline',
                'link' => '/users',
                'permissions' => [
                    'users.index'
                ],
            ],
            [
                'name' => 'strings.purchase_orders',
                'icon' => 'file-text-outline',
                'link' => '/purchase-orders',
                'permissions' => [
                    'purchase_orders.index'
                ],
            ],
        ];

        $response = $this->withHeaders([
                'Authorization' => 'Bearer '.$this->adminToken,
            ])
            ->json(
                'GET',
                '/api/vue'
            )
            ->assertStatus(200)
            ->assertHeader('Content-Type', 'application/json')
            ->assertJson([
                'menuItems' => $menuItems,
                'notifications' => []
            ]);
    }
}
