Improve mocking and debugging with web instance (#91)
This commit is contained in:
23
source/app/mocks/api/github/rest/repos/getViews.mjs
Normal file
23
source/app/mocks/api/github/rest/repos/getViews.mjs
Normal file
@@ -0,0 +1,23 @@
|
||||
/** Mocked data */
|
||||
export default function({faker}, target, that, [{owner, repo}]) {
|
||||
console.debug(`metrics/compute/mocks > mocking rest api result > rest.repos.getViews`)
|
||||
const count = faker.random.number(10000)*2
|
||||
const uniques = faker.random.number(count)*2
|
||||
return ({
|
||||
status:200,
|
||||
url:`https://api.github.com/repos/${owner}/${repo}/traffic/views`,
|
||||
headers:{
|
||||
server:"GitHub.com",
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
},
|
||||
data:{
|
||||
count,
|
||||
uniques,
|
||||
views:[
|
||||
{timestamp:`${faker.date.recent()}`, count:count/2, uniques:uniques/2},
|
||||
{timestamp:`${faker.date.recent()}`, count:count/2, uniques:uniques/2},
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user