Skip to content

Commit

Permalink
feat: add support for @allcontributors (one word) (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolam authored Jan 27, 2019
1 parent 90841af commit acb5118
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/utils/isMessageForBot.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function isMessageForBot(message) {
const lowerCaseMessage = message.toLowerCase()
const isMessageForBot =
message.includes(`@all-contributors`) ||
message.includes(`@allcontributors[bot]`)
lowerCaseMessage.includes(`@all-contributors`) ||
lowerCaseMessage.includes(`@allcontributors`) ||
lowerCaseMessage.includes(`@allcontributors[bot]`)
return isMessageForBot
}

Expand Down
20 changes: 16 additions & 4 deletions test/utils/isMessageForBot.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const isMessageForBot = require('../../src/utils/isMessageForBot')

describe('isMessageForBot', () => {
const testBotName = 'all-contributors'

test('For us', () => {
expect(
isMessageForBot(
`@${testBotName} please add jakebolam for doc, infra and code`,
`@all-contributors please add jakebolam for doc, infra and code`,
),
).toBe(true)

Expand All @@ -15,12 +13,26 @@ describe('isMessageForBot', () => {
`@allcontributors[bot] please add jakebolam for doc, infra and code`,
),
).toBe(true)

expect(
isMessageForBot(
`@allcontributors please add jakebolam for doc, infra and code`,
),
).toBe(true)
})

test('For us, case in-sensitive', () => {
expect(
isMessageForBot(
`@aLL-conTRIBUtors 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`,
`all-contributors please add jakebolam for doc, infra and code`,
),
).toBe(false)

Expand Down

0 comments on commit acb5118

Please sign in to comment.