const gitlab = require('../routes/gitlab') //const axios = require('axios') //jest.mock('axios') describe('GitLab API', () => { /* test('jest.fn recalls what it has been called with', () => { const mock = jest.fn() mock('a', 'b', 'c') expect(mock).toHaveBeenCalledTimes(1) expect(mock).toHaveBeenCalledWith('a', 'b', 'c') }); */ // mock /* it('returns an existing gitlab-userID by an email address', done => { let resp = { error: false, data: 1} axios.get.mockResolvedValue(resp) gitlab.getUserIdByEmail('rosanny.sihombing@hft-stuttgart.de', function(resp){ try { expect(resp.error).toBeFalsy() expect(resp.data).not.toBeNull() done() } catch (error) { done(error) } }) }) */ it('returns an existing gitlab-userID by an email address', done => { gitlab.getUserIdByEmail('rosanny.sihombing@hft-stuttgart.de', function(data){ try { expect(data.error).toBeFalsy() expect(data.data).not.toBeNull() done() } catch (error) { done(error) } }) }) it('returns an error due to the non-exist user', done => { gitlab.getUserIdByEmail('test@hft-stuttgart.com', function (data) { try { expect(data.error).toBeTruthy() done() } catch (error) { done(error) } }) }) it('returns the projects of a particular userId', done => { gitlab.getUserProjects(3, function (data) { try { expect(data.error).toBeFalsy() expect(data.data).not.toBeNull() done() } catch (error) { done(error) } }) }) it('returns an error due to the wrong userID', done => { gitlab.getUserProjects('abc', function (data) { try { expect(data.error).toBeTruthy() done() } catch (error) { done(error) } }) }) })