{"size": 1551, "ext": "js", "max_stars_repo_path": "Server/test/questionsHandler.test.js", "max_stars_repo_name": "DavidOdun/TrueGroups", "max_stars_repo_stars_event_min_datetime": "2020-01-29T16:44:11.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-29T16:44:11.000Z", "max_issues_repo_path": "Server/test/questionsHandler.test.js", "max_issues_repo_name": "DavidOdun/TrueGroups", "max_issues_repo_issues_event_min_datetime": "2020-01-28T19:45:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T07:36:55.000Z", "max_forks_repo_path": "Server/test/questionsHandler.test.js", "max_forks_repo_name": "DavidOdun/TrueGroups", "max_forks_repo_forks_event_min_datetime": "2020-04-11T00:54:57.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-17T02:18:20.000Z"}
{"max_stars_count": 1, "max_issues_count": 12, "max_forks_count": 2, "avg_line_length": 36.9285714286, "max_line_length": 116, "alphanum_fraction": 0.6885880077}
const app = require('../main/app'); // Link to your server file
const supertest = require('supertest');
const request = supertest(app);

question_ids = {};

test('add first question test, should succeed', async done => {
    let question = {question_string: "This is the first question."};
    const response = await request.post('/api/v1/questions/add').send(question);
    expect(response.status).toBe(200);
    question_ids[question.question_string] = response.body[0].question_id;
    done();
});

test('add second question test, should succeed', async done => {
    let question = {question_string: "This is the second question."};
    const response = await request.post('/api/v1/questions/add').send(question);
    expect(response.status).toBe(200);
    question_ids[question.question_string] = response.body[0].question_id;
    done();
});


test('get all questions test, should succeed', async done => {
    const response = await request.get('/api/v1/questions/all');
    expect(response.status).toBe(200);
    expect(response.body.length > 0);
    done();
});


test('remove first question test, should succeed', async done => {
    const response = await request.post('/api/v1/questions/remove/' + question_ids["This is the first question."]);
    expect(response.status).toBe(200);
    done();
});

test('remove second question test, should succeed', async done => {
    const response = await request.post('/api/v1/questions/remove/' + question_ids["This is the second question."]);
    expect(response.status).toBe(200);
    done();
});