{"size": 797, "ext": "js", "max_stars_repo_path": "__mocks__/node-fetch.js", "max_stars_repo_name": "bochkarev/homebridge-tion", "max_stars_repo_stars_event_min_datetime": "2019-09-12T04:23:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-15T11:57:37.000Z", "max_issues_repo_path": "__mocks__/node-fetch.js", "max_issues_repo_name": "bochkarev/homebridge-tion", "max_issues_repo_issues_event_min_datetime": "2019-11-12T21:37:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-09T21:29:27.000Z", "max_forks_repo_path": "__mocks__/node-fetch.js", "max_forks_repo_name": "bochkarev/homebridge-tion", "max_forks_repo_forks_event_min_datetime": "2021-09-28T13:39:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-31T16:24:35.000Z"}
{"max_stars_count": 35, "max_issues_count": 21, "max_forks_count": 2, "avg_line_length": 22.7714285714, "max_line_length": 65, "alphanum_fraction": 0.6047678795}
const authTestData = require('./data/auth.json');
const locationTestData = require('./data/location.json');

const node_fetch = jest.genMockFromModule('node-fetch');

function auth(options) {
    return {
        ok: true,
        json: () => Promise.resolve(authTestData)
    };
}

function location(options) {
    return {
        ok: true,
        json: () => Promise.resolve(locationTestData)
    };
}

node_fetch.__initialize = () => {
}

node_fetch.default = (url, options) => {
    switch (url) {
        default: 
            throw new Error('Unknown url');
        case 'https://api2.magicair.tion.ru/idsrv/oauth2/token': 
            return auth(options);
        case 'https://api2.magicair.tion.ru/location':
            return location(options);
    }
}

module.exports = node_fetch;
