
/* eslint no-unused-vars: off */

"use strict"

process.env.NODE_ENV = "test"

const chai = require("chai")
const chai_http = require("chai-http")
const config = require("../config")

const should = chai.should()
const expect = chai.expect
chai.use(chai_http)

const RestApi = require("../dist/lib/api")

const api = new RestApi({}, { port: config.api.port })
api.initialize()

const server = api.server

describe("REST API", () =>
{
    it("GET /api/v1/operators", (done) =>
    {
        chai.request(server)
            .get("/api/v1/operators")
            .end((error, resp) =>
            {
                should.not.exist(error)
                resp.status.should.equal(200)
                resp.body.should.not.be.undefined
                resp.body.should.have.property("status")
                resp.body.should.have.property("data")
                resp.body.status.should.be.a.string
                expect(resp.body.status).to.be.equal("ok")
                resp.body.data.should.be.an("array")
                resp.body.data.should.have.lengthOf.above(0)
                resp.body.data[0].should.have.property("name")
                resp.body.data[0].should.have.property("uid")
                resp.body.data[0].should.have.property("description")
                done()
            })
    })
})
