forked from github-tools/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecord.js
More file actions
34 lines (32 loc) · 1.16 KB
/
record.js
File metadata and controls
34 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import fs from 'fs';
import nock from 'nock';
import path from 'path';
import GitHub from '../../lib/GitHub';
import testUser from './user.json';
const gh = new GitHub();
let fileName;
gh.getRateLimit().getRateLimit()
.then((resp) => {
if (resp.data.rate.remaining === 0) {
fileName = 'repos-ratelimit-exhausted.js';
} else {
fileName = 'repos-ratelimit-ok.js';
}
nock.recorder.rec({
dont_print: true
});
gh.getUser(testUser.USERNAME).listRepos();
setTimeout(() => {
const fixtures = nock.recorder.play();
const filePath = path.join(__dirname, fileName);
const text = ('/* eslint-disable */\n' +
'import nock from \'nock\';\n' +
'export default function fixture() {\n' +
' let scope;\n' +
' scope = ' + fixtures.join('\nscope = ').trim().replace(/\n/g, '\n ') + '\n' +
' return scope;\n' +
'}\n');
fs.writeFileSync(filePath, text);
console.log('Wrote fixture data to', fileName);
}, 10000);
}).catch(console.error);