import test from 'ava'; import nock from 'nock'; var check = require('./check'); import allContributorsCliResponse from './fixtures/all-contributors.response.json'; import allContributorsCliTransformed from './fixtures/all-contributors.transformed.json'; import reactNativeResponse1 from './fixtures/react-native.response.1.json'; import reactNativeResponse2 from './fixtures/react-native.response.2.json'; import reactNativeResponse3 from './fixtures/react-native.response.3.json'; import reactNativeResponse4 from './fixtures/react-native.response.4.json'; import reactNativeTransformed from './fixtures/react-native.transformed.json'; test.before(() => { nock('https://api.github.com') .persist() .get('/repos/jfmengels/all-contributors-cli/contributors?per_page=100') .reply(200, allContributorsCliResponse) .get('/repos/facebook/react-native/contributors?per_page=100') .reply(200, reactNativeResponse1, { Link: '; rel="next", ; rel="last"' }) .get('/repositories/29028775/contributors?per_page=100&page=2') .reply(200, reactNativeResponse2, { Link: '; rel="next", ; rel="last", ; rel="first", ; rel="prev"' }) .get('/repositories/29028775/contributors?per_page=100&page=3') .reply(200, reactNativeResponse3, { Link: '; rel="next", ; rel="last", ; rel="first", ; rel="prev"' }) .get('/repositories/29028775/contributors?per_page=100&page=4') .reply(200, reactNativeResponse4, { Link: '; rel="first", ; rel="prev"' }); }); test('Handle a single results page correctly', async t => { const transformed = await check('jfmengels', 'all-contributors-cli'); t.deepEqual(transformed, allContributorsCliTransformed); }); test('Handle multiple results pages correctly', async t => { const transformed = await check('facebook', 'react-native'); t.deepEqual(transformed, reactNativeTransformed); });