Skip to content

Commit

Permalink
test: update nock mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mesaugat committed Mar 11, 2024
1 parent 6eb5157 commit b1c848b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scheduler/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ const { Probot, ProbotOctokit } = require('probot')

const payload = require('./fixtures/installation-created.json')

nock.disableNetConnect()

describe('Schedules intervals for a repository', () => {
let probot

beforeEach(() => {
nock.disableNetConnect()
probot = new Probot({
githubToken: 'test',
// Disable throttling & retrying requests for easier testing
Expand All @@ -23,7 +22,7 @@ describe('Schedules intervals for a repository', () => {
createScheduler(probot)
})

it('gets a page of repositories', async () => {
test('gets a page of repositories', async () => {
nock('https://api.github.com')
.get('/app/installations')
.query({ per_page: 1 })
Expand All @@ -37,13 +36,20 @@ describe('Schedules intervals for a repository', () => {
.persist()

nock('https://api.github.com')
.get('/app/installations?per_page=100')
.get('/app/installations')
.query({ per_page: 100 })
.reply(200, [{ account: { login: 'testUser' } }])

nock('https://api.github.com')
.get('/installation/repositories?per_page=100')
.get('/installation/repositories')
.query({ per_page: 100 })
.reply(200, [{ id: 2 }])

await probot.receive({ name: 'installation', payload })
})

afterEach(() => {
nock.cleanAll()
nock.enableNetConnect()
})
})

0 comments on commit b1c848b

Please sign in to comment.