import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { HeaptraderAPI } from './api';
import { expect, jest, test } from '@jest/globals';

class HeaptraderAPITest extends HeaptraderAPI
{
    public _mock: MockAdapter;

    constructor()
    {
        super("");
        this._mock = new MockAdapter(axios);
        this.setupMockResponses();
    }

    setupMockResponses(): void
    {
        this._mock.onGet("/up").reply(200, {});
    }
}

test('check uptime', async () => {
    const api = new HeaptraderAPITest();
    const success = await api.heartbeat();
    expect(success).toBe(true);
});
