-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: in some cases usernames are not correctly parsed (#20)
* test: add test cases that are failing * wip
- Loading branch information
Showing
7 changed files
with
107 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { GIHUB_BOT_NAME } = require('./settings') | ||
|
||
function isMessageForBot(message) { | ||
const isMessageForBot = message.includes(`@${GIHUB_BOT_NAME}`) | ||
return isMessageForBot | ||
} | ||
|
||
module.exports = isMessageForBot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const isMessageForBot = require('../../src/utils/isMessageForBot') | ||
|
||
describe('isMessageForBot', () => { | ||
const testBotName = 'AllContributorsBotTest' | ||
|
||
test('For us', () => { | ||
expect( | ||
isMessageForBot( | ||
`@${testBotName} please add jakebolam for doc, infra and code`, | ||
), | ||
).toBe(true) | ||
|
||
expect( | ||
isMessageForBot( | ||
`@AllContributorsBotTest please add jakebolam for doc, infra and code`, | ||
), | ||
).toBe(true) | ||
}) | ||
|
||
test('Not for us', () => { | ||
expect( | ||
isMessageForBot( | ||
`${testBotName} please add jakebolam for doc, infra and code`, | ||
), | ||
).toBe(false) | ||
|
||
expect( | ||
isMessageForBot(`Please add jakebolam for doc, infra and code`), | ||
).toBe(false) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,55 @@ | ||
const parseComment = require('../../../src/utils/parse-comment') | ||
const { GIHUB_BOT_NAME } = require('../../../src//utils/settings') | ||
|
||
describe('parseComment', () => { | ||
const testBotName = 'AllContributorsBotTest' | ||
|
||
test('Basic intent to add', () => { | ||
expect( | ||
parseComment( | ||
`@${GIHUB_BOT_NAME} please add jakebolam for doc, infra and code`, | ||
`@${testBotName} please add jakebolam for doc, infra and code`, | ||
), | ||
).toEqual({ | ||
action: 'add', | ||
who: 'jakebolam', | ||
contributions: ['doc', 'infra', 'code'], | ||
}) | ||
}) | ||
|
||
test('Basic intent to add - non name username', () => { | ||
expect( | ||
parseComment(`@${testBotName} please add tbenning for design`), | ||
).toEqual({ | ||
action: 'add', | ||
who: 'tbenning', | ||
contributions: ['design'], | ||
}) | ||
}) | ||
|
||
test('Basic intent to add - captialized username', () => { | ||
expect( | ||
parseComment(`@${testBotName} please add Rbot25_RULES for tool`), | ||
).toEqual({ | ||
action: 'add', | ||
who: 'Rbot25_RULES', | ||
contributions: ['tool'], | ||
}) | ||
}) | ||
|
||
test('Intent unknown', () => { | ||
expect( | ||
parseComment(`@${testBotName} please lollmate for tool`), | ||
).toEqual({ | ||
action: false, | ||
}) | ||
}) | ||
// | ||
// test('Basic intent to add (with plurals)', () => { | ||
// expect( | ||
// parseComment( | ||
// `@${GIHUB_BOT_NAME} please add jakebolam for docs, infra and code`, | ||
// ), | ||
// parseComment(`@${testBotName} please add dat2 for docs`), | ||
// ).toEqual({ | ||
// action: 'add', | ||
// who: 'jakebolam', | ||
// contributions: ['doc', 'infra', 'code'], | ||
// who: 'dat2', | ||
// contributions: ['doc'], | ||
// }) | ||
// }) | ||
}) |