Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagoda11 committed May 30, 2024
1 parent 1353aaf commit 8a7358a
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,62 @@ describe('index.js', () => {

expect(nock.isDone()).toBe(true);
});

test('creates a comment when a pull request is opened', async () => {
// Mock GitHub API
nock('https://api.github.com')
.post('/repos/test/test/issues/1/comments')
.reply(200, {});

// Mock 'pull_request.opened' event
const event = {
id: '1234',
name: 'pull_request',
payload: {
action: 'opened',
pull_request: {
number: 1,
title: 'Test pull request',
body: 'This is a test pull request',
},
repository: {
owner: {
login: 'test',
},
name: 'test',
},
},
};

await probot.receive(event);

expect(nock.isDone()).toBe(true);
});

test('responds to pull request closed', async () => {

Check warning on line 118 in test/index.test.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Test has no assertions

Check warning on line 118 in test/index.test.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Test has no assertions
// Mock GitHub API
nock('https://api.github.com')
.post('/repos/test/test/issues/1/comments')
.reply(200, {});

// Mock 'pull_request.closed' event
const event = {

Check warning on line 125 in test/index.test.js

View workflow job for this annotation

GitHub Actions / build (21.x)

'event' is assigned a value but never used

Check warning on line 125 in test/index.test.js

View workflow job for this annotation

GitHub Actions / build (21.x)

'event' is assigned a value but never used
id: '1234',
name: 'pull_request',
payload: {
action: 'closed',
pull_request: {
number: 1,
title: 'Test pull request',
body: 'This is a test pull request',
},
repository: {
owner: {
login: 'test',
},
name: 'test',
},
},
};
});
});

0 comments on commit 8a7358a

Please sign in to comment.