<?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();

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

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

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